How to make a node follow the camera

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
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.
I started to write the AI code for my FPS,and I started from writing a function that makes a node follow the camera :

Code: Select all

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

	irr::scene::ISceneNodeAnimator* anim = smgr->createFlyStraightAnimator (enemystart, 
		core::vector3df(camera->getPosition().X,camera->getPosition().Y,camera->getPosition().Z),  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
Post Reply