14.5 C
New York
Monday, November 10, 2025

Why would not my inflexible physique transfer once I press the buttons? I do not see any motive why I should not


He "Automotive" in query is an airplane. The query is self-explanatory.

Right here is the automotive within the hierarchy:

Right here is the automotive on the inspector:

unit inspector

And right here is the PlayerMovement script:

utilizing UnityEngine;

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

    public float drive = 500f;

    void FixedUpdate()
    {
        if (Enter.GetKey("w") || Enter.GetKey("up"))
        {
            Debug.Log("Foreward");
            rb.AddForce(0, 0, drive * 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(drive * Time.deltaTime, 0, 0);
        }
    }
}

Reveals the "ahead" log in once I press W or the up arrow so I do know it is working.

(Facet observe: I do know this may not get me began on the precise physics of the automotive, I am simply attempting to verify I can transfer the automotive first)

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles