Moving third person object on all axes
Page 1 of 1 • Share •
Moving third person object on all axes
Ok, this is a pretty noob question, but here it is:
How do I move an object through space, on all axes? Like a space ship that can rotate an move up or down on x, y, and z. Using setLinearVelocity() is fine and good for moving an object the remains on the ground and only needs to move on the y and x axes, but how do I move on the z? I'm using the tutorial09 as a learning tool (because it has an example of 3rd person camera), but I can't seem to figure out what I need to do. Hence my plea to you fine people. Any help would be greatly appreciated.
Thanks.
How do I move an object through space, on all axes? Like a space ship that can rotate an move up or down on x, y, and z. Using setLinearVelocity() is fine and good for moving an object the remains on the ground and only needs to move on the y and x axes, but how do I move on the z? I'm using the tutorial09 as a learning tool (because it has an example of 3rd person camera), but I can't seem to figure out what I need to do. Hence my plea to you fine people. Any help would be greatly appreciated.
Thanks.
CadetCrusher- Posts : 21
Join date : 2009-10-07
Re: Moving third person object on all axes
setLinearVelocity is exactly what you need... as you are navigating in 0 gravity... the direction vector passed to setLinearVelocity can be concatenated using the different values of your navigation controller, it is not only good for "ground" movement but for all kind of directional movements.
_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
sio2interactive- Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai
Re: Moving third person object on all axes
Thanks for the reply! I appreciate it.
Forgive my ignorance, but how would I concatenate the direction value to reflect where the player is pointing?
setLinearVelocity(btVector3(x, y, ?))
I'm loving the SDK so far, thanks!
Forgive my ignorance, but how would I concatenate the direction value to reflect where the player is pointing?
setLinearVelocity(btVector3(x, y, ?))
I'm loving the SDK so far, thanks!
CadetCrusher- Posts : 21
Join date : 2009-10-07
Re: Moving third person object on all axes
Well you got a direction vector (where the ship points to), then if the player hold up left, you want to move up and left... so... you take the direction vector and do the necessary rotation on Z then you add the up factor to it... the result is a new direction vector, "concatenated" (maybe I shouldn't use that word actually).
_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
sio2interactive- Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai
Re: Moving third person object on all axes
I hate to ask for more help, but, my 3d fundamentals are lacking (you have to start somewhere right?). So, here's what I'm doing (mostly based on tutorial09):
The above works in the x,y plane but I can't figure out how to make the ship move in the direction it is pointing. The value of object->_SIO2transform->dir is (0,0,0). What am I missing? How do I correctly calculate the direction vector for the ship and the correct velocity vector?
Thanks again for all your help.
- Code:
// this code is heavily edited for brevity, I've only listed what I believe to be important
// rotate the player ("ship") to the correct orientation
// here the variable object is the ship
object->_SIOtransform->rot->z = ROTZ;
object->_SIOtransform->rot->x = ROTX;
object->_SIOtransform->rot->y = ROTY;
sio2TransformBindMatrix(object->_SIO2transform);
// do all the collision detection and placement for the camera (same as tutorial09, omitted here for brevity)
object->_SIO2objectphysic->_btRigidBody->setActivationState(ACTIVE_TAG);
object->_SIO2objectphysic->_btRigidBody->setLinearVelocity(btVector3( (MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->x) * SPEED, (MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->Y) * SPEED, (MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->z) * SPEED));
The above works in the x,y plane but I can't figure out how to make the ship move in the direction it is pointing. The value of object->_SIO2transform->dir is (0,0,0). What am I missing? How do I correctly calculate the direction vector for the ship and the correct velocity vector?
Thanks again for all your help.
CadetCrusher- Posts : 21
Join date : 2009-10-07
Re: Moving third person object on all axes
dir == normalize( linear velocity )
_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
sio2interactive- Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai
Re: Moving third person object on all axes
Thanks for helping out. But it seems I need to get my 3D fundamentals a lot better because I'm just not seeing how all this comes together. I've been coding for years, just not games, so this is all new to me. Does anyone have any examples (sample code) of how to achieve the movement I'm attempting? Or at the very least a good book/website for learning the fundamentals of 3D game development?
Thanks!
Thanks!
CadetCrusher- Posts : 21
Join date : 2009-10-07
Re: Moving third person object on all axes
The SIO2_SDK is a good base to start... go through all the tutorials & video tutorials, then when you are ready you might consider the purchase of MeditationGarden to check how to create an advanced game architecture, link everything together etc...
_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
sio2interactive- Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

» Discussion: Let's say you're the first person to make alien contact
» THE GAMES FACTORY 2
» New, looking for single person meal
» Am I the only normal person on PO?
» Moving Trees Cross Country
» THE GAMES FACTORY 2
» New, looking for single person meal
» Am I the only normal person on PO?
» Moving Trees Cross Country
Permissions in this forum:
You cannot reply to topics in this forum