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 / angles question

Author
Message
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 15th Nov 2003 21:25
i have it so when i hit enter it "throws" a grenade from object 1.
but my problem is, i dont know what way object 1 is facing.
what i want it to do is throw it at a distance of pwr toward the way object 1 is faceing. any ideas how i might go about doing this?

Two words, moo.
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 15th Nov 2003 21:42
object orientation y(1) should work. or just keep track of your player's y-rotation in a variable, like roty#, then when you change the player's orientation, change the variable and update it at the end with rotate object 1,0,roty#,0. hope that helps.
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 15th Nov 2003 21:50
i have never seen the command object orientation y(1) before in my life, and apparently DB hasnt either (searched through all the help files and such, not there). you know im doing this in 3d right? if so, why am i looking at the y angle at all? i dont care if its looking up or down, i just want to know where it is facing

Two words, moo.
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 15th Nov 2003 23:05
When you throw the grenade, get the current player y-rotation [object angle y() if you aren't already keeping track of the angle] and then store it to a variable like gre_angley#. Now, you simply need to move the grenade with newxvalue() and newzvalue():

gre_x# = newxvalue(gre_x#, gre_angley#, gre_forward_velocity#)
gre_z# = newzvalue(gre_z#, gre_angley#, gre_forward_velocity#)

And remember that gre_forward_velocity# comes from the 2d physics equation that I gave you earlier. Remember that, like a plain, 2d can be rotated in any direction in a 3d world. This value will be equal to COS(angle_from_ground#)*throwing_force#.

Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 16th Nov 2003 04:25
i'm sorry, it was object angle not object orientation, heh. and you use the y-angle because that is the axis the object rotates about in the situation you describe.
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 16th Nov 2003 04:40
simple graphic representation

JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 17th Nov 2003 07:12
oh, duh, ok i see.

Two words, moo.

Login to post a reply

Server time is: 2025-05-21 16:35:17
Your offset time is: 2025-05-21 16:35:17