Sign in to follow this  

3d Movement with Origin and Vector (Angles)

This topic is 2586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm not a super math type, but I'm still interested in learning. I've been working on this game that I've been developing in blender, but I need some help on my php server end.

Basically, the server needs to calculate the next given location of a player.

My input is:
x,y,z and roll/pitch/yaw along with the distance travelled.

This is what I have so far, but I realised it's totally wrong. Was wondering if someone could help me out?

$this->current_x = $this->current_x + $distance * cos(deg2rad($a)) * sin(deg2rad($z));
$this->current_y = $this->current_y + $distance * sin(deg2rad($a)) * sin(deg2rad($z));
$this->current_z = $this->current_z + $distance * cos(deg2rad($z));

Share this post


Link to post
Share on other sites
Ok, so i found an example on some obscure forum. My final code ended up being:


$a = $this->current_yaw;
$z = -$this->current_pitch;

// orig
$this->current_x += $distance * cos(deg2rad($a)) * cos(deg2rad($z));
$this->current_y += $distance * sin(deg2rad($a)) * cos(deg2rad($z));
$this->current_z += $distance * sin(deg2rad($z));


Thought i'd share that with you all!

Share this post


Link to post
Share on other sites

This topic is 2586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this