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
How to make a node follow the camera
-
- Posts: 3
- Joined: Tue Jun 29, 2010 1:12 am
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.
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.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
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.