I can't get my spider-shaped rigidbody game object to rotate correctly. To test out the Rigidbody capabilities, I've given a capsule a basic movement function.
void Move(Vector3 position)
{
previousPosition = transform.position;
Vector3 direction = position - transform.position;
direction.y = 0;
if (direction.magnitude < 0.2F)
{
if (num == (waypoints.Length - 1)) num = 0;
else num++;
return;
}
// Rotate towards the target
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(direction), 1 * Time.deltaTime);
rigidbody.AddRelativeForce(transform.forward, ForceMode.VelocityChange);
}
This capsule is supposed to follow a series of waypoints, but it's going in the wrong direction and off the expected path completely. To be more specific, the capsule turns is some odd direction, and then continues to move in that direction and never changes its direction. I really hope someone will want to help me. I know the physics in Unity can be quite complex, but it's also widely used - so hopefully there is someone who has had this problem before.