Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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);
beamRight.Normalize();
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:

http://i.imgur.com/FOKLx.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;
share|improve this question
1  
I'm not very familiar with XNA anymore, but isn't there a Matrix.LookAt() function available? – Benjamin Danger Johnson Nov 8 '12 at 19:33
i tried Matrix.CreateLookAt but it resulted in the model displaying flat with no moment :( – Sparky41 Nov 9 '12 at 9:15
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/… – Benjamin Danger Johnson Nov 9 '12 at 17:45

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.