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.

Newcomers DBPro Corner / Arghh...Rotation problems

Author
Message
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 15th Jul 2004 08:20
*sigh* have to make another post...

Anyway, my code right now is about 310 lines, but i realized just now that you cant exactly turn, you can only move forwards, backwards, and strafe either way. i want to add a feature where you can actually turn, by using..well for now just make it the "G' key for turning left, and the "H" key for turning right (rotating). How do i do this? I know I have to use wrapvalue (from the 3d monster hunt tutorial) but its not doing anything. can someone help me? Here my code.

SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 15th Jul 2004 13:44 Edited at: 15th Jul 2004 13:46
Well, with your current code that's going to be a little bit of a headache, because you've assumed that different key assignments change the values of certain variables. When you rotate, or turn to face left for example, your forward code now changes the X direction and not the Z variables, while the left and right arrows now change Z. So, you need to do two things;

1. Add a variable that contains which direction the player is facing, which changes the values of both X and Z speed accordingly. this is probably best done by getting the sine and cosine of the current direction and multiply by your speed value, remembering to sign the result for the proper quadrants for the direction faced. (Althouh, if you limit to 90 degree turns only, this is just the signs and integer values that change, no interpolation using sine and cosine.)

2. And, you need to change your current movement code to add/subtract both of the new X & Z values from the player and camera positions.

Any truly great code should be indisguishable from magic.
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 15th Jul 2004 15:29
hmm okay thanks i get what you mean, but what do you mean by
Quote: "
this is probably best done by getting the sine and cosine of the current direction and multiply by your speed value, remembering to sign the result for the proper quadrants for the direction faced. (Althouh, if you limit to 90 degree turns only, this is just the signs and integer values that change, no interpolation using sine and cosine.)
"

I understand what sine, cosine, and tangent means (i have taken geometry class), but how do they help in this case? Not exactly sure where you're going with that...coudl you explain a little more?

Thanks
RougeCat
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Xdrome
Posted: 15th Jul 2004 16:33 Edited at: 15th Jul 2004 16:36
Using CURVEVALUE() command works better than sin or cos commands. There have been couple of cool car physics that have been posted here be4 and I found this 1 more intresting. U can try implementing this technique in urs.


Ps:Just click on the source button to view the source code.
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 16th Jul 2004 01:53
Thanks for the response (yaar ), but u didnt post any code . i will look at the curvevalue command.

Ps- Neengul Tamil paseh?
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 16th Jul 2004 07:08
Ah yeah, thanks RougeCar, I'm not fully thinking of the DB commands in my head as yet...

Indian Homie G,
What I meant was like for "normal" 3D movement processes, like heading say, North-West which is a 45 degree angle. Then using sine and cosines, or the curvevalue command, can return the amounts of X and Z step to add to the character's position for each step taken. It's a rotational coordinate thing... more for free flight.
S.

Any truly great code should be indisguishable from magic.
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 16th Jul 2004 12:54
hmmm...that makes a bit more sense. So what your saying is, if im traveling at a 45 degree angle, im going lets say 5 units in the Z axis, and 5 units in the x axis? to determine the lengths i would use sines and cosines and tangents... is that what your're getting at? makes sense to me..

also, can darkbaswic find the inverse sine and inverse cosine?

Thanks a bunch
RougeCat
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Xdrome
Posted: 16th Jul 2004 15:52
If u click on the source button next to the profile button rite below my previous post u can see the code.



Ps: naan nallavey tamizh paesuvaen
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 16th Jul 2004 19:54
Yep, Indian Homie G, that's what I was saying. Like traveling at a 30 degree angle would be .5 and .86. Again, using sine & cosine to determine the values.

good luck with it!
S.

Any truly great code should be indisguishable from magic.
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 17th Jul 2004 02:08
thanks bro ill try it out!

Login to post a reply

Server time is: 2024-09-22 16:23:32
Your offset time is: 2024-09-22 16:23:32