Game Development Reference
In-Depth Information
How it works...
With each update, the nine rays we create are placed in a circle around the character, with
one in the center.
They will check for collisions with a surface below them. If any of them (this might be
changed to two or three) does not hit something within okDistance , it will be reported
as the character being close to a dangerous edge.
The okDistance has to be set to something suitable, higher than a step on a stair, prob-
ably at a height where the player could take damage.
When this happens, the animation manager will be called with the NearEdge action set to
true . This will apply the jumping animation (wild flaying of the arms) to the upper body
of the character while still allowing other animations to be played on the lower part.
The NearEdge Boolean is used to make sure that we only send the call to the animation
manager once.
When doing collision checks, one should be careful about the amount and shape of the ob-
jects that are being collided. If the world is large or constructed from complex shapes (or
even worse, if it has MeshCollisionShape ), we should try to find optimized ways of
applying the method. One way could be to separate the world into parts and have an auxili-
ary method to select which part to collide against. This method might use contains on
BoundingVolume to see the part the player is located in.
Search WWH ::




Custom Search