NAS24
NAS24
CC#
Created by NAS24 on 7/7/2023 in #help
❔ 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
9 replies