Skip to main content
GameDev.net gamedev.net
🔒 Locked

Aiming a gun

Started by Festermt Apr 27, 2001 at 11:28 PM 0 replies 200+ views
Original Post
Festermt
Festermt
I have two 3d xfile meshes, 1 is the player ,the other is the gun, I have no problem rotating the gun around with the player, but I have no idea how to aim the gun depending on what angle they are facing. If the gun is turned to 0 degrees than I rotate it around the z axis, if the gun is turned to 90 degrees then I rotate it around the x axis to aim it, but what if the gun is turned to 10 or some other odd number degrees. How do you calculate how much to rotate each axis to keep the gun straight as you are aiming it. Any examples would be great, I program in vb but i am just looking for the math or which dx function to use anyway so if you use c++ it shouldnt matter. Thanks in advance, Mike Tari mtari@mnsi.net
SirKnight
SirKnight
Well you could take the direction vector for your character and use it for the gun also. So that way, the gun will be looking down the same vector as the player.

-SirKnight

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.