How to calculate position with inclination

Hello,

I would like to use moveposition on rigidbody but the target position has to be calculate with a rotation without rotating my player.

My player move with this way :

rb.MovePosition(transform.position + transform.forward * Time.fixedDeltaTime * speed);

When an inclination occur, I would like to move above the inclination without rotating my player.
I have the inclination angle (Vector3).

Can you help me please.

Thanks :slight_smile:

Sorry, I am probably completely missing the problem here… You want to move your body up a known angle slope and wish to know the new y position?

If so, you can use Mathf.Tan(angle) [angle is in radians] * horizontal distance to get the vertical (y) change.

If you want constant speed, then Vector3.Clamp it to the displacement you require.

I’m assuming you are not going anywhere near a 90 degree slope? Tan is not the approach for that problem.