So I want to make it so instead of the character just moving left and right, I want it to rotate towards that direction then move in that direction, like most games, but I keep finding things that just rotate the player forever like a beyblade
So if you press βDβ, the player will rotate right then move forward? If so, you can use transform.Rotate()
to do this. Hereβs some untested code that might do that:
public class PlayerMovement : MonoBehaviour
{
public float RotateSpeed;
void Update()
{
Rotate();
}
void Rotate()
{
// 'A' rotates left
if (Input.GetKey(KeyCode.A))
{
transform.Rotate(new Vector3(0f, -RotateSpeed, 0f));
}
// 'D' rotates right
if (Input.GetKey(KeyCode.D))
{
transform.Rotate(new Vector3(0f, RotateSpeed, 0f));
}
}
}