运行时不报错,但不能控制。

运行时不见任何报错信息,但是却不能正常控制目标胶囊。这就很苦恼了,,或提供一点调查的方向。另外,unity有没有可以看到代码执行过程的功能?或许有助于我找到问题。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerBehavior : MonoBehaviour

{
public float moveSpeed = 10f;
public float rotateSpeed = 75f;
public float jumpVelocity = 5f;
//1
public float distanceToGround = 0.1f;
//2
public LayerMask groundLayer;
private float _vInput;
private float _hInput;
private Rigidbody _rb;
//3
private CapsuleCollider _col;
void Start()
{
_rb = GetComponent();
//4
_col = GetComponent();
}
void Update()
{
_vInput = Input.GetAxis("Vertical") * moveSpeed;
_hInput = Input.GetAxis("Horizontal") * rotateSpeed;
//5
if (IsGrounded() && Input.GetKeyDown(KeyCode.Space))
{
_rb.AddForce(Vector3.up * jumpVelocity, ForceMode.Impulse);
}
}
void FixedUpdate()
{

}
//6
private bool IsGrounded()
{
    //7
    Vector3 capsuleBottom = new Vector3(_col.bounds.center.x, _col.bounds.min.y, _col.bounds.center.z);
    //8
    var grounded = Physics.CheckCapsule(_col.bounds.center, capsuleBottom, distanceToGround, groundLayer, QueryTriggerInteraction.Ignore);
    return grounded;
}

}

建议写一些打印语句,查看打印信息是否符合预期值;或者debug进行跟踪调试。

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632