unity3D js代码问题
发布网友
发布时间:2022-06-25 15:50
我来回答
共1个回答
热心网友
时间:2024-12-02 04:28
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
public float speed = 6.0f;
public float jumpspeed = 8.0f;
public float gravity = 20.0f;
private Vector3 movedirection = Vector3.zero;
private bool grounded = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
if (grounded) {
movedirection = new Vector3(Input.GetAxis("Horizonta"),0,Input.GetAxis("Vertical")) ;
movedirection = transform.TransformDirection(movedirection);
movedirection *= speed;
if(Input.GetButton("jump")){
movedirection.y = jumpspeed;
}
}
movedirection.y -= gravity * Time.deltaTime;
bool flags = GetComponent<CharacterController> ().Move (movedirection * Time.deltaTime);
grounded = (flags & CollisionFlags.CollidedBelow)! = 0;
}
}
CollisionFlags.CollidedBelow这个是什么?