steve c,
Yes,
sin and
cos can be used for this. First, you need to make sure that your gun's orientation(angle) on the y axiz, is the same as the camera's angle. To say, that if your camera's angle is initially 20o on the y axis, then your gun should also intially be pointing at 20o on the y axis. If not, you should use commands to rotate and set your gun model's initial angle. These commands and their syntax's are:
YROTATE OBJECT Object Number, Y
FIX OBJECT PIVOT Object Number
Use
YROTATE OBJECT to rotate your gun model, on the y axis, to be facing straight away from the camera, intitally. Then, use
FIX OBJECT PIVOT to make the new angle of rotation your gun's absolute rotation. Now, your gun should be facing away from the camera and your rotation values should be 0, if so-be all was done correctly.
To make the gun ride along in front of the camera is a little tricky. However, with a bit of practice you can master the technique. I have attached to this post 'SOURCE' code of a 2D program I have written specifically for you to study with. The program includes no media, and is a top-down view representation of how you would set up your gun to ride with the camera. Good luck to you, and be patient in learning this method. When I first began learning
sin and
cos, it took me many experimentations before I ever grasped the concept.
To conclude, you would use this same approach to have the gun look up and down with you. Just, use the math on the X angle in 3D space.
+NanoBrain+