Page 1 of 1

Node following another Node

Posted: Wed Apr 28, 2004 4:10 pm
by Dark_Exodus
Hi

How would you get a node to follow another node? For example a player with an enemy character chasing after him. I know it's a bit of a generalised question :roll: but can anyone point me in the right direction?


Also is it possible to display time.

Posted: Wed Apr 28, 2004 4:46 pm
by arras
thats simple AI what you need.

Basicly:
get coordinates of target object (player)
rotate chasing object to face target (enemy)
move chasing object forward
check if chasing ob. is not coliding with target

you have to do it periodicly (each loop or each X loops)

Posted: Wed Apr 28, 2004 4:49 pm
by arras
about time ...there is function to get time in Irrlicht ...i dont remember sintax, check documentation.

Posted: Thu Apr 29, 2004 11:48 am
by Dark_Exodus
ok thanks, I don't think I totally understand but I'll give it a shot. Also I've looked in the documentation and can't find anything about displaying time.

Posted: Thu Apr 29, 2004 2:05 pm
by arras
virtual u32 irr::ITimer::getTime() [pure virtual]

rotating

Posted: Tue May 11, 2010 4:18 pm
by kamikaze942
rotate chasing object to face target (enemy)
how would i go about doing this? I've got everything set up, but the chasing isn't working because of this.

Posted: Tue May 11, 2010 7:12 pm
by Mag-got
From this thread: http://irrlicht.sourceforge.net/phpBB2/ ... php?t=1325

By squisher

Code: Select all

vector3df nodePos = node->getPosition();
vector3df targetPos = targetNode->getPosition();
vector3df diff = targetPos - nodePos;

node->setRotation(diff.getHorizontalAngle());
node->updateAbsolutePosition();

Posted: Wed May 12, 2010 4:01 am
by kamikaze942
nice! don't suppose you know how to convert that over to bullet rotations eh?

Posted: Wed May 12, 2010 2:26 pm
by Mag-got
You mean the physics library? What does it need to be, degrees, radians, quaternion?

Posted: Wed May 12, 2010 5:39 pm
by kamikaze942
well i'm using this code for it

Code: Select all

btMatrix3x3 orn = rigidbody->getWorldTransform().getBasis();
orn *= btMatrix3x3(btQuaternion(btVector3(0,1,0), 0.06));
rigidbody->getWorldTransform().setBasis(orn);
looks like they are using quats for it. i'm going to take a loot at it some more later.