How to make a node follow the camera

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
shabadam
Posts: 10
Joined: Sat Jul 03, 2004 11:39 am
Location: Italy

How to make a node follow the camera

Post by shabadam »

Hi.
Sorry if I repost this , but I got to answers in the Advanced forum.

Hi.
I started to write the AI code for my FPS,and I started from writing a function that makes a node follow the camera :
--------------------------------------------------------------------------------

void follow(scene::IAnimatedMeshSceneNode * enemy,scene::ISceneManager* smgr,scene::ISceneNode * camera)
{
core::vector3df enemystart = enemy->getPosition();

irr::scene::ISceneNodeAnimator* anim = smgr->createFlyStraightAnimator (enemystart,
camera->getPosition(), ENEMY_FOLLOWSPEED, false ) ;
enemy->addAnimator(anim);

}
--------------------------------------------------------------------------------

This code works , in the sense that the node actually follows the camera , but it seems that the collision response animator stops working on the node in question. The result is that the node pass through walls and floats in the air.
I thought that if a node is already affected by gravity, the FlyStraight animator would only make the node move in the given direction , but following the floor and the stairs , and not on a straight line.
Is there a way to make two or more animators coexist in the same node , or there's something wrong in the code ?
Should I use something else than the FlyStraight animator ?
Thanx in advance
pincherman
Posts: 3
Joined: Tue Jun 29, 2010 1:12 am

Post by pincherman »

The tutorial says it's a cool stuff to mix animators, but please, the is no way they coexist!

What's the idea to have a unusefull collision renponse animator if there is no way to use it? the admins always advice using bullet or another phys engine, so.....

stop using animators.
Xaryl
Posts: 90
Joined: Sat Apr 30, 2011 11:54 pm

Post by Xaryl »

FlyStraightAnimator leaves no room for proper gravity/collision animation; It doesn't matter where the new position the collision response animator set the node to, FlyStraightAnimator sets the node right back onto the line.

You can try an animator (probably need to code one) that takes the node position into account in each "animateNode (ISceneNode *node, u32 timeMs)" call that moves the node base on the position at that frame.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yeah, mixing animators is difficult. You could try to attach the fly straight animator first, and then the collision animator. This could at least stop the mesh from crossing walls. However, proper stairs movement is not necessarily achievable, as the collision animator would probably move the mesh just back on a direct line.
Post Reply