Game Development Reference
In-Depth Information
How to do it
Follow the following algorithm to achieve the wall avoidance behavior in the project:
1. The visual explanation of the technique is shown in the following screenshot:
2. Create feelers that will sense the wall:
Front_Feeler = player->Get velocity; // vector
Front_Feeler = Front_Feeler.normalize(); // vector
This will project the feeler in front of the player.
Front_Feeler = Front_Feeler * FeelerLength; // vector
Front_Feeler = Front_Feeler + player->location;
3. Now we have got the Front_Feeler so let's apply the force in the same direc-
tion. This force will push the player away from the wall.
4. To fine-tune the behavior even more, you can additionally add two more feelers on
the either side of the player. This will help player to take a more smooth turn and
look realistic.
Search WWH ::




Custom Search