Answer the question
In order to leave comments, you need to log in
How to calculate the motion vector?
I am currently making my PlayerController based on a Rigidbody. I move on an inclined surface, and depending on the slope I move not only in x and z, but also in y:
Here is my code:
float groundAngle = (float)System.Math.Acos(Mathf.Clamp(groundNormal.y, -1, 1)) * 180 / (float)System.Math.PI;
rigidbody.AddRelativeForce((direction + Vector3.up * groundAngle / 45) * speed, mode);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question