Unity 3D RidgidBody.AddForce 不动

问题描述 投票:0回答:1

我有以下对象和玩家控制器

private float turnSpeed = 45.0f;
private float horizontalInput;
private float forwardInput;
public bool hasDelivery = false;
public bool hasPowerUp = false;
public GameManager1 gameManager;
private Rigidbody rb;
// Start is called before the first frame update
void Start()
{
    rb = GetComponent<Rigidbody>();
    gameManager = GameObject.Find("GameManager").GetComponent<GameManager1>();
}

//(0.00, 0.00, 1.34)"
void FixedUpdate()
{
    forwardInput = Input.GetAxis("Vertical");
    horizontalInput = Input.GetAxis("Horizontal");

    Vector3 movement = transform.forward * forwardInput * speed;
    rb.AddForce(movement * speed);

    float turn = horizontalInput * turnSpeed * Time.fixedDeltaTime;
    Quaternion turnRotation = Quaternion.Euler(0f, turn, 0f);

    //rb.AddTorque(transform.up * turn);
    rb.MoveRotation(rb.rotation * turnRotation);
}

enter image description here

当我尝试移动物体时,什么也没有发生。任何帮助将不胜感激

unity-game-engine
1个回答
0
投票

尝试将其更改为非运动学。

© www.soinside.com 2019 - 2024. All rights reserved.