Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / lock object on thing

Author
Message
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 26th Mar 2005 19:23
can anyone help me to put my gun infrot of the screen without using lock object on because using lock object on makes it seethrough ihave heard u can use sin cos and tan but i have no idea how so can anyone help pls oh and it has to follow the screen werever u looklike up and down and left and right

current projects = codename : tasgarad
despite what it sais to the left joined 5 december 03
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 27th Mar 2005 02:01 Edited at: 27th Mar 2005 02:04
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+
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 27th Mar 2005 22:37
okay thanks this is my code so far

the only troulble that gives is that it doesent follow up and down and when u run forward it moves ahead of the camera.

so the gun is pointing directly away from the screen and follows the camera left and right,i know the sin and cos stuff can fix that but i had no idea where to start with it i need some more help on where to start with it pls thanks.

current projects = codename : tasgarad
despite what it sais to the left joined 5 december 03

Login to post a reply

Server time is: 2025-05-31 05:24:34
Your offset time is: 2025-05-31 05:24:34