way facing vector

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
raptorstrike

way facing vector

Post by raptorstrike »

ok i want to be able to shoot out a bullet and have the velocity set to go the dirrection i have shot how do i acheve this in irrlicht?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Code: Select all

irr::core::vector3df r = irr::core::vector3df(0,0,velocity);

irr::core::matrix4 m;
m.setRotationDegrees( node->getRotation() );

m.transformVect(r);

node->setPosition( node->getPosition() + r );
where node is your bullet node.
raptorstrike

Post by raptorstrike »

ok this moves the object in a set direction i want the direction that the object travles to be dynamic (changing all the time)
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

then you need to define modification value lets name it acceleration:

Code: Select all

irr::core::vector3df acceleration = irr::core::vector3df(0,0,0.5f);

irr::core::vector3df velocity = irr::core::vector3df(0,0,0);
then in your main loop you change velocity each frame:

Code: Select all

velocity = velocity + acceleration;
then you use code above to move object
Post Reply