Game Development Reference
In-Depth Information
Objective complete - mini debriefing
In this section, we created a script called the CharacterControl script that we can use to
control the character's movement by using the Move() function in the CharacterControl-
ler component. This function needs the Vector3 direction passed in and returns Colli-
sionFlags , which are very convenient to track the position of the character that has been
collided.
Note
We can get CollisionFlags by accessing the CharacterController component, which in
our case, can be done using _characterController.collisionFlags . For ex-
ample, we can use this flag to check if the character only hits the ceiling by using the fol-
lowing expression:
If (_characterController.collisionFlags ==
CollisionFlags.Above) {…}
For more detail, visit http://docs.unity3d.com/Documentation/ScriptReference/Colli-
sionFlags.None.html .
We also applied GRAVITY while the character falls down from the jump or from the plat-
form where there is no collider. Also, we used the OnAnimatorMove() function to con-
trol the animation state.
Search WWH ::




Custom Search