I'm trying to keep a 3d plane facing the camera at all angles but while i have some success with this:

Vector3 gunToCam = cam.cameraPosition - getWorld.Translation;
Vector3 beamRight = Vector3.Cross(torpDirection, gunToCam);
Vector3 beamUp = Vector3.Cross(beamRight, torpDirection);
shipeffect.beamWorld = Matrix.Identity;
shipeffect.beamWorld.Forward = (torpDirection) * 1f;
shipeffect.beamWorld.Right = beamRight;
shipeffect.beamWorld.Up = beamUp;
shipeffect.beamWorld.Translation = shipeffect.beamPosition;

*Note: Logic not wrote by me i just found this rather useful

It seems to only face the camera at certain angles. For example if i place the camera behind the plane you can see it that only Roll's around the axis like this:

https://i.stack.imgur.com/0sLfy.png (imagine if you are looking from behind where you have fired from.

Any idea what to what the problem is (angles are not my specialty)

shipeffect is an object that holds this class variables:
public Texture2D altBeam;
public Model beam;
public Matrix beamWorld;
public Matrix[] gunTransforms;
public Vector3 beamPosition;
  • 1
    \$\begingroup\$ I'm not very familiar with XNA anymore, but isn't there a Matrix.LookAt() function available? \$\endgroup\$ Nov 8, 2012 at 19:33
  • \$\begingroup\$ i tried Matrix.CreateLookAt but it resulted in the model displaying flat with no moment :( \$\endgroup\$
    – Sparky41
    Nov 9, 2012 at 9:15
  • \$\begingroup\$ Interesting, well there are many ways to do this, and I don't feel like re-posting the answer (many people have the same problem) so here is a like to a similar post: gamedev.stackexchange.com/questions/15070/… \$\endgroup\$ Nov 9, 2012 at 17:45


Browse other questions tagged .