For example, I want “w” to move the character up on the screen no matter which way the character is rotated. Is there a way to do this?
Of course, rotation doesn’t affect movement (unless you have a script that makes it do so).
Ill assume this is a 2d game since you use the word “up” instead of “forward”.
Heres some code that will make the player move up and down with the “w” and “s” keys. Modify it to fit your needs.
public float speed;
private Rigidbody2D rigidbody;
void Start()
{
rigidbody = GetComponent<Rigidbody2D> ();
}
void FixedUpdate()
{
float moveVertical = Input.GetAxis ("Vertical");
Vector2 movement = new Vector2 (0, moveVertical);
rigidbody.AddForce (movement * speed);
}