1)Hi, i am implementing a movement system for a RTS game, i tried to use the function createFlyStraightAnimator but i saw that the animator has to be done within a x time, is there a way to use this animator based on a speed instead of time?
2)Is there a way to know when createFlyStraightAnimator is done?I mean, a way to createFlyStraightAnimator advice me when the unit reaches its destination.
3)Lets consider that my map is a circle, i have a unit turned to the circunference of the circle at 180 degree. Then, i click in the position x of this circle, so how can i know what angle should i rotate my unit in order to him stay facing that position? (confuse question, hope you understand).
Thank you!
FlyStraightAnimator (movement stuff in general)
-
- Posts: 1
- Joined: Mon Dec 04, 2006 5:16 pm
1) Yes, ever do physics at school? Remember Time = Distance/Speed? So with that you can work out what the amount of time should be depending on the required speed and you can easily work out the distance between your start and end points.
2) You'll know how long it's going to take so you could just use a timer to see if that amount of time has elapsed yet.
3) Do you mean that your unit moves around the circumference of the circle and always faces along the line of the circle? Or faces into the centre?
2) You'll know how long it's going to take so you could just use a timer to see if that amount of time has elapsed yet.
3) Do you mean that your unit moves around the circumference of the circle and always faces along the line of the circle? Or faces into the centre?
-
- Posts: 1
- Joined: Mon Dec 04, 2006 5:16 pm
1 and 2) Thank you
3)How can i explain? Its a odinary situation, i have a unit standing in a place, i pick that unit and tell it to move to position x, but when the unit is moving, the unit isnt facing the place that it is going, it is facing the same place that it was facing before it started runing ex: a unit running towards a dog and looking to a cat(not just looking, but the whole body turned to the cat).
3)How can i explain? Its a odinary situation, i have a unit standing in a place, i pick that unit and tell it to move to position x, but when the unit is moving, the unit isnt facing the place that it is going, it is facing the same place that it was facing before it started runing ex: a unit running towards a dog and looking to a cat(not just looking, but the whole body turned to the cat).
Ahh much better explanation! Here's where i explained the same thing the other day
http://irrlicht.sourceforge.net/phpBB2/ ... atmatrixlh
http://irrlicht.sourceforge.net/phpBB2/ ... atmatrixlh
-
- Posts: 1
- Joined: Mon Dec 04, 2006 5:16 pm
it seems that it isn´t working, let´s consider that my unit is on a circle. He´s looking to 90 degrees in the circle, when i click for him to walk to 0 degree, he stays looking to 90 degree, if hes looking to 0 degree and i click to 90 degree, it will keep looking to 90, if hes looking to 180 degree and i click to continue in 180 degree, he looks at 0 degree. Got it? The explanation is litlle bit confusing again sorry.
-
- Posts: 1
- Joined: Mon Dec 04, 2006 5:16 pm
Code: Select all
if (device->getSceneManager()->getSceneCollisionManager()->getCollisionPoint(
line, selector, intersection, tri))
{
animTargetNode->setMD2Animation(scene::EMAT_RUN);
f64 distance = animTargetNode->getPosition().getDistanceFrom(intersection);
intersection.Y = animTargetNode->getPosition().Y;
f64 time = distance/0.02;
scene::ISceneNodeAnimator* anim =
device->getSceneManager()->createFlyStraightAnimator(animTargetNode->getPosition(),
intersection, time, false);
animTargetNode->addAnimator(anim);
anim->drop();
animTimer = device->getTimer()->getTime();
finishAnimTimer = time + animTimer;
matrix4 m;
m.buildCameraLookAtMatrixLH(animTargetNode->getPosition(),
intersection, vector3df(0,1,0));
animTargetNode->setRotation(m.getRotationDegrees());
}
hello all! i suppose it is a right place for my question, so i decided to ask this here.
could you tell me is it ok to calculate vector of movement according to current node's rotation in a way like this below (i want my node to move to new position which is achieved in accordance to its current rotation, i.e. in a direction it is looking at on this moment):
is it ok to use such code for this?
thanks for help!
could you tell me is it ok to calculate vector of movement according to current node's rotation in a way like this below (i want my node to move to new position which is achieved in accordance to its current rotation, i.e. in a direction it is looking at on this moment):
Code: Select all
//get Node's current rotation
core::vector3df curRotation = _caller->getRotation();
//vector of new movement (we don't use Y coordinate here, right?)
core::vector3df movedir(1,0,1);
core::matrix4 mat;
mat.setRotationDegrees( core::vector3df( 0, curRotation.Y, 0 ) );
mat.transformVect(movedir);
movedir.normalize();
//and then our final destination point will be:
core::vector3df newPosition = movedir * ourSpeedValue * 500;
is it ok to use such code for this?
thanks for help!