double MaxSpeedInDirection(Vector3 desiredMovementDirection)
{
if (desiredMovementDirection == Vector3.zero)
return 0;
else {
double zAxisEllipseMultiplier = (desiredMovementDirection.z > 0 ? movement.maxForwardSpeed : movement.maxBackwardsSpeed) / movement.maxSidewaysSpeed;
float dMD = (float)desiredMovementDirection.x;
float uio = (float)(desiredMovementDirection.z / zAxisEllipseMultiplier);
Vector3 temp = new Vector3(dMD, 0, uio).normalized;
float t1 = (float)temp.x; float t2 = (float)(temp.z * zAxisEllipseMultiplier);
double length = new Vector3(t1, 0, t2).magnitude * movement.maxSidewaysSpeed;
return length;
}
}