Overall rigidBodies and character controllers are very reliable when using the built-in Move(velocity) functions.
However, severe problems always tend to arrive when trying to move a gameobject with an attached rigid body / character controller to a specific location in a scene. It seems to break the character controller.
Consider the following scenario:
- You have a character controller moving with
characterController.Move (currentMoveDirection * Time.deltaTime *1.0f);
- You execute some instructions to move the character controller manually using:
characterController.transform.position = ...
or
characterController.gameObject.transform.position = ...
- Suddenly the character controller pops up and floats above the ground, some distance much greater than that it was before.
- The controller continually reports that it is “grounded”, when it is many units above the collider it is on.
These issues do not happen until you start doing step 2 above.
The character controller can settle itself down again once you start bumping into different ground colliders.
Even the API provides no function for moving a character controller to a specific location, which makes me wonder why not.
Even the isGrounded member is a little suspicious: “Was the CharacterController touching the ground during the last move?” (Unity - Scripting API: CharacterController.isGrounded)
Note it doesnt report if it is currently touching the ground, which could be the reason why the above issues are occuring.
So, is there a reliable way to “teleport” a gameObect with a character controller without causing problems to the character controller?