O'Reilly logo

Windows Phone 7 XNA Cookbook by Zheng Yang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing sphere-triangle collision detection

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.

How to do it...

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, change Game1.cs to CameraModelCollisionGame.cs. Meanwhile, add Triangle.cs and TriangleSphereCollisionDetection.cs to the project. Then, create a Content Pipeline Extension Library ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required