© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
8 replies
NAS24

❔ Need help trying to make 2D car move from above

// {
        if (Input.GetKeyDown(KeyCode.W) == true)
        {
            myRigidbody.velocity = Vector2.up * 1;
        }
        if (Input.GetKeyUp(KeyCode.W) == true)
        {
            myRigidbody.velocity = Vector2.zero;
        }
        if (Input.GetKeyDown(KeyCode.A) == true)
        {
            myRigidbody.transform.Rotate(new Vector3(0, 0, 90));
        }
    }
// {
        if (Input.GetKeyDown(KeyCode.W) == true)
        {
            myRigidbody.velocity = Vector2.up * 1;
        }
        if (Input.GetKeyUp(KeyCode.W) == true)
        {
            myRigidbody.velocity = Vector2.zero;
        }
        if (Input.GetKeyDown(KeyCode.A) == true)
        {
            myRigidbody.transform.Rotate(new Vector3(0, 0, 90));
        }
    }


With this code I can only move it up and rotate left 90 degrees. I want to be able of rotating it 90 degrees left and then when I press W it keeps moving in the left direction. Some kind of forward code
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

I need to make this textbox not move
C#CC# / help
2y ago
Trying to install C# need help troubleshooting
C#CC# / help
2y ago