?
?
public class PZ : MonoBehaviour {
CharacterController huang;//角色控制器
public GameObject shape;//玩家
public float speed = 50f;//移动速度
void Start () {
huang = GetComponent<CharacterController>();//获取角色控制
}
void Update () {
float h = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
float v = Input.GetAxis("Vertical") * Time.deltaTime * speed;
if (Input.GetKeyDown(KeyCode.Space))
{
transform.position += Vector3.up;
}
huang.SimpleMove(new Vector3(h, 0, v));
}
//碰撞检测
void OnControllerColliderHit(ControllerColliderHit other)
{
print(other.gameObject.name);//碰撞检测,返回被碰撞物体名字
}
}
|