Node following another Node

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Dark_Exodus
Posts: 23
Joined: Thu Jan 29, 2004 4:07 pm
Location: Birmingham, UK
Contact:

Node following another Node

Post 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.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post 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)
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

about time ...there is function to get time in Irrlicht ...i dont remember sintax, check documentation.
Dark_Exodus
Posts: 23
Joined: Thu Jan 29, 2004 4:07 pm
Location: Birmingham, UK
Contact:

Post 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.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

virtual u32 irr::ITimer::getTime() [pure virtual]
kamikaze942
Posts: 52
Joined: Wed Mar 03, 2010 7:11 pm

rotating

Post 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.
Kamikaze
Mag-got
Posts: 42
Joined: Tue Dec 04, 2007 5:53 pm

Post 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();
kamikaze942
Posts: 52
Joined: Wed Mar 03, 2010 7:11 pm

Post by kamikaze942 »

nice! don't suppose you know how to convert that over to bullet rotations eh?
Kamikaze
Mag-got
Posts: 42
Joined: Tue Dec 04, 2007 5:53 pm

Post by Mag-got »

You mean the physics library? What does it need to be, degrees, radians, quaternion?
kamikaze942
Posts: 52
Joined: Wed Mar 03, 2010 7:11 pm

Post 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.
Kamikaze
Post Reply