How do I get my solution to go forward or right on the world axis

In order to get the desired player movement I have directly changed the velocity.

            PlayerRB.velocity = new Vector3(xInput * movementSpeed, PlayerRB.velocity.y,zInput * movementSpeed);

But the problem is I want it to be able to go forward or right depending where the transform is looking at.

Assuming you’re using 3D Meshes on a 3D world space, and that you’re using Physics and Rigidbody instead of their counterparts (Physics2D, Rigidbody2D), I might tell ya NOT to use velocity if you wanna use Physics moves.

Actually, velocity is a headache if you don’t know how to use it. Only set it to make jumps. Use AddForce() instead of velocity. Like this:

var someSpeed = Input.GetAxis("Horizontal") * 10;
PlayerRB.AddForce(transform.right * someSpeed * Time.fixedDeltaTime, ForceMode.Force); //Goes right (x axis)

Use transform.right to move on the x axis, transform.forward to move on the z axis and transform.up to move on the y axis.


Also, set the x/z velocity to zero after you move the player, otherwise he’ll surely slide.

PlayerRB.velocity = new Vector3 (0, PlayerRB.velocity.y, 0);

But remember, physics movements work better inside FixedUpdate(), which runs on a fixed amount of time, close enough to the Physics callback.

Hope I’ve helped.