Moving third person object on all axes
2 posters
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.
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).
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
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...
Similar topics
» Moving an Object before physic
» Congratulating the 1.3.1 version
» Move Convex Hull character (like zombie in Tutorial 15) around in third person in sio2 V1.4
» Transformations not happening
» Camera moving
» Congratulating the 1.3.1 version
» Move Convex Hull character (like zombie in Tutorial 15) around in third person in sio2 V1.4
» Transformations not happening
» Camera moving
Permissions in this forum:
You cannot reply to topics in this forum