# first person mesh placment

This topic is 4632 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

im creating a 3D first person networked game, my problem is how do I get the meshes to face the same direction as the camera, as in if im in the game and there is another player in and there moving forward how do I make sure that the mesh that represents them is facing the right direction. im using C# and directX 9 april update...

##### Share on other sites
Smacker,

You can store the angle about the vertical axis which they are facing. That is, if I'm using a left-handed coordinate system and my character is facing down the world Z axis (90deg about Y) and I rotate to my left, I'm now facing, lets say, 45 degrees left of the z-axis(135deg about Y).

You can build a rotation matrix from the Euler angle. You can then use this rotation matrix to transform the character into his rotated position. Keep in mind that this rotation needs to be performed in local space, not world space. So remember to transform the model before putting him in world space.

Cheers and good luck!

##### Share on other sites
now seeing that im sending the clients camera lookat position, and the camera eye location, couldent I just use the cameras lookat position vector3?

and also how do I go about seting the rotation before the world transform

right now im using

dev.Transform.World = Matrix.Transformation(ect...);

##### Share on other sites
also what rotation matrix would I use the objects that im moving are space ships, so I was using RotationYawPitchRoll but this is not working here is what I have done

ma.Transform(new Vector3(), Quaternion.Identity, new Vector3(.3f,.3f,.3f), new Vector3(), Quaternion.RotationMatrix(Matrix.RotationYawPitchRoll(d_point.Y, d_point.X, 0.0f)) ,b_point);

then place it in the world

Device.Transform.World = ma;
then I draw the mesh...

##### Share on other sites
Use the inverse of your view transform. In the other player's view, the entire world is moved to be in his own coordinate system. In this player, the other player needs to be move. So seems to me it's the inverse of the transform.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 11
• 9
• 9
• 42
• ### Forum Statistics

• Total Topics
634131
• Total Posts
3015716
×