Make player movement not relative to units current orientation

Hey guys,
I’m currently working on 3D top down shooter.
I want to controll my player movement with a xbox controller the same way as in games like “Gauntlet” or “Hellerdivers”. The aiming (turning arround) with the right stick works. The problem is that I dont’ want the movement to depend on the direction the character is facing.

When I move the controller to the left the player should move to the left (no matter its orientation).
This is my code:

 void FixedUpdate()
    {
        // Amount to Move
        float MoveVertical = Input.GetAxis("VerticalPlayer" + player.playerId) * movementSpeed * Time.deltaTime;
        float MoveHorizontal = Input.GetAxis("HorizontalPlayer" + player.playerId) * movementSpeed * Time.deltaTime;

        float MoveRotateHorizontal = Input.GetAxisRaw("RotateHorizontal" + player.playerId);//  * rotateSpeed * Time.deltaTime;
        float MoveRotateVertical = Input.GetAxisRaw("RotateVertical" + player.playerId);

        if (MoveRotateHorizontal != 0 || MoveRotateVertical != 0)
        {
            float angle = Mathf.Atan2(MoveRotateHorizontal, MoveRotateVertical) * Mathf.Rad2Deg;
            transform.eulerAngles = new Vector3(0, angle + aimAngleOffset, 0);
        }

        // Move the player
        Vector3 movement = new Vector3(MoveHorizontal, 0, MoveVertical);

      
        transform.Translate(Vector3.forward * MoveVertical);
    }

the term you need to look up is “unity camera relative movement”, it keeps coming up and there are loads of resources to look at to resolve this out there.

thanks for your reply. I got this working :slight_smile: Do you have another keyword to make the movement so the player turns with an animation instead of just instantly looking that way?

well, there is literally “root motion animations” (probably not what you want give you’re already controlling movement with code), or looking up lerp/slerp and/or coroutines