Friday, October 24, 2025
spot_img

Why is my rigidbody not transferring after I press the buttons? I am unable to see any purpose it should not


The "Automotive" in query is a aircraft. The query is fairly self explanatory.

This is the Automotive within the Hierarchy:

Why is my rigidbody not transferring after I press the buttons? I am unable to see any purpose it should not

This is the automotive within the inspector:

Unity Inspector

And here is the PlayerMovement script:

utilizing UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    // --------------------------------
    // References
    // --------------------------------
    public Rigidbody rb;
    // --------------------------------

    public float pressure = 500f;

    void FixedUpdate()
    {
        if (Enter.GetKey("w") || Enter.GetKey("up"))
        {
            Debug.Log("Foreward");
            rb.AddForce(0, 0, pressure * Time.deltaTime);
        }
        if (Enter.GetKey("a") || Enter.GetKey("left"))
        {
            rb.AddForce(-force * Time.deltaTime, 0, 0);
        }
        if (Enter.GetKey("s") || Enter.GetKey("down"))
        {
            rb.AddForce(0, 0, -force * Time.deltaTime);
        }
        if (Enter.GetKey("d") || Enter.GetKey("proper"))
        {
            rb.AddForce(pressure * Time.deltaTime, 0, 0);
        }
    }
}

It does present the "Foreward" log after I press W or up arrow, so I do know that is working.

(Aspect word: I do know this would possibly not get me precise automotive physics, I am simply making an attempt to ensure I can transfer the automotive in any respect first)

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles