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.

Dark GDK / Moving a player (rigid body) forward with sin and cos

Author
Message
samqweqwe
6
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 8th Jul 2013 02:26 Edited at: 9th Jul 2013 01:35
hi, i have a player that i would like to change to a rigid body but have to change the movement code to do this as dbMoveObject is not compatable with these rigid bodies(i think so).

I tried to use the linear velocity to move it which worked but did not all ways move it in the right Direction:




The players X and Z angle never changle from 0 but Y rotates when the mouse moves.

is there something wrong with the maths?
can anyone fix this?
thanks in advance

EDIT: im not sure if this is the cause but dbObjectAngleY(player) returns a value with 10 digits, why is it not 0 - 359?
Zotoaster
14
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 11th Jul 2013 19:02 Edited at: 11th Jul 2013 19:04
If the X and Z angles never change, then the velocity should simply be:

vX = sin(angy) * 10
vY = 0
vZ = cos(angy) * 10


If you want to change the X angle, use this:

vX = sin(angy) * cos(angx) * 10
vY = -sin(angx) * 10
vZ = cos(angy) * cos(angx) * 10

(Not used this in a while so I may be wrong, but the first one is definitely correct)

Edit: Corrected the last one, still not sure if it's exactly right

"everyone forgets a semi-colon sometimes." - Phaelax

Login to post a reply

Server time is: 2019-09-19 19:59:58
Your offset time is: 2019-09-19 19:59:58