In FPS game, when the character moves forward to a building or a wall and contacts the object, it will stop and stand there. And you know there is no object around you, because the camera is your eye in the FPS game. If you wonder how the game developers achieve this, you will find the answer in this recipe.
The following steps will show you the best practice of applying the sphere-triangle collision detection for first-person perspective camera:
1. Create a Windows Phone Game project named
CameraModelCollision
, changeGame1.cs
toCameraModelCollisionGame.cs
. Meanwhile, addTriangle.cs
andTriangleSphereCollisionDetection.cs
to the project. Then, create a Content Pipeline Extension Library project namedMeshVerticesProcessor
and replace theContentProcessor1.cs
withMeshVerticesProcessor.cs
. After that, insert the 3D model fileBigBox.fbx
and sprite font filegameFont.spriteFont
to the content project.2. Define the
MeshVerticesProcessor...