Hi All,
This is probably a very simple and obvious problem but I’m buggered if I can think of a solution.
As my character controller approaches it’s destination it slows up, like a linear ramp down.
I suspect it’s because my targetvdir gets smaller as it gets nearer the end. My question is what do I have to
do to my code example to make the controller move at a constant rate right to it’s destination?
Vector3 targetvdir = TargetPosition - CurrentPosition;
if(targetvdir != Vector3.zero)
{
Quaternion targetdir = Quaternion.LookRotation(targetvdir);
CurrentRotation= Quaternion.Slerp(CurrentRotation, targetdir, 2 * Time.deltaTime); /* Rotate towards the target */
CurrentRotation.eulerAngles = new Vector3(0, CurrentRotation.eulerAngles.y, 0);
}
Vector3 forwardDir = targetvdir;
forwardDir = forwardDir * speed;
controller.SimpleMove(forwardDir);