Rotate a vector WITH transform.

Hello, I am working on a top down game in which the player is able to move in eight directions, forward, back, left, right and diagonals. The direction is established through vector3 and is a rigidbody force. This is controlled by WASD. I want the arrow keys to control the camera angle in 90 degree increments. However the vector3 stays the same, so that pressing up would move the character right according to the newly rotated camera. How would I go about rotating the vector?

What you want to do is use “transform.forward” in your code instead of Vector3.forward.

Vector3.forward is in world space and always goes in one direction based on world space. “transform.forward” goes forward in the gameObject’s local space.