Moving according to the angle of my characters

Hi,
I have start unity and I create a third person view game, i can move forward and backward and look at right and left with this script:

    Rigidbody rb;
   public float walkspeed;
     
float zmov = Input.GetAxisRaw("Vertical");
        rb.velocity = new Vector3(0, rb.velocity.y, zmov) * walkspeed;
      
float xmov = Input.GetAxisRaw("Horizontal");
        Quaternion deltaRotation = Quaternion.Euler(angleVelocity * Time.fixedDeltaTime * xmov);

I just want to move according to the angle of deltarotation please

I am making assumptions here, so I might be wrong.

You are using W and S to move forward and backward and A and D to turn.

The easiest way to do this is to rotate with A and D, THEN use transform.forward for the direction to move.

rb.velocity = transform.forward * Input.GetAxisRaw("Vertica") * walkSpeed;

The order is important, rotate then move not move then rotate.

1 Like

Thanks a lot! it working perfectly