O'Reilly logo

3D Game Development with Microsoft Silverlight 3 Beginner's Guide by Gastón C. Hillar

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

Time for action—working with torques and rotations

Your project manager is planning to add more physics simulations to the game. He wants the UFO to rotate around its Y-axis. However, it must follow the physics laws and the rotation could occur while applying forces and/or impulses to the UFO. Hence, you must use the physics simulator capabilities to avoid buying a physics law book.

We are now going to use Farseer Physics Engine to add a torque affecting the UFO's rotation.

  1. Stay in the project 3DInvadersSilverlight.
  2. Open Ufo.cs.
  3. Add the following line of code before the end of the class' constructor:
    Body.RotationalDragCoefficient = 0.2f;
    
  4. Add the following line of code before the end of the Update method:
    _mesh.World = Balder.Core.Math.Matrix.CreateRotationY(FarseerGames.FarseerPhysics.Mathematics.MathHelper.ToDegrees(Body.Rotation)); ...

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