Apply a translation
Apply a translation
Hi,
For my shooting function, I'd like that the bullet start at the right hand of my enemy.
But I don't know how to do that, how can I make a translation ???
Can you help me please, it's only maths...
For my shooting function, I'd like that the bullet start at the right hand of my enemy.
But I don't know how to do that, how can I make a translation ???
Can you help me please, it's only maths...
Hi,
I do it that way:
First you need the target vector:
Second: You update your bullet's position with this vector (which you have to store once in your bullet class):
Regards - Xaron
I do it that way:
First you need the target vector:
Code: Select all
// Set target vector for the weapon
core::matrix4 rotMatrix;
rotMatrix.setRotationDegrees( player->getRotation() );
core::vector3df targetVec = core::vector3df( 0.0f, 0.0f, 1.0f );
rotMatrix.transformVect( targetVec );
Code: Select all
position += targetVec * static_cast< float >( velocity * timeDiff ) / 1000.0f;
node->setPosition( position );
How come? If you display the enemy including the weapon you have the enemy's scene node. If the weapon is a child of the enemy (this makes things much easier), you can simply get the weapon's position, too. Or is the enemy including the weapon one mesh/model? If yes you still have the relative position of the weapon, haven't you?goutbouyo wrote:But the problem is that I don't have the position of the enemy's weapon.
Regards - Xaron
-
- Posts: 48
- Joined: Thu Jun 15, 2006 6:35 pm
Goutbouyo, you could always just use some trial and error, if you are using the MD2 models I assume you will have some sort of 'firing' animation, so the weapon will always be in the same position relative to the model's position in the world (like Xaron said), so you could just make a reasonable guess and then keep adjusting it until it is right.
I know this isn't a very pleasing solution (the offset could be different for each model) but as far as I know there are no bones you can use in an MD2 model (they use vertex animation, not skeletal) to find the gun position.
I know this isn't a very pleasing solution (the offset could be different for each model) but as far as I know there are no bones you can use in an MD2 model (they use vertex animation, not skeletal) to find the gun position.