Activate an Animation after a collision

Tano_ITA

12-06-2008 20:07:03

Hi,
i've this problem.. I need to activate the "Die" animation when two body collide.. So this is my userProcess:

int RobotDieCallBacks::userProcess()
{

mAnimationRobot = entRobot->getAnimationState("Die");
mAnimationRobot->setEnabled(true);
return 1;
}


But when a ball collide with my robot, the animation start just with the first frame.. But i want all animation.. I don't have problem with animation with the rest of project, but i don't know why in this case the animation start the first frame only..

anyone can help me? thank a lot..

Sorry for my bad english..

albino

13-06-2008 07:56:08

i think you have to update the animation state
in the main loop by adding this


mAnimationRobot->addTime(evt.timeSinceLastFrame);

Tano_ITA

13-06-2008 08:39:01

I solved the problem writing this code in userBegin(). But i don't know why this work in userBegin() e not in the userProcess().

pra

13-06-2008 11:53:10

i think you should put it in userEnd.
userProcess could be called multiple times, since it is called one time for each contact, userEnd is then called when all the contacts are through and Newton knows how the actual collision will look like.
You should also read about the 3 functions in the OgreNewt_ContactCallback.h file, it's explained there

Tano_ITA

19-06-2008 10:31:30

i think you should put it in userEnd.
userProcess could be called multiple times, since it is called one time for each contact, userEnd is then called when all the contacts are through and Newton knows how the actual collision will look like.
You should also read about the 3 functions in the OgreNewt_ContactCallback.h file, it's explained there


Yes i undestand this but i don't know how i can complete the robot's animation and not animate just the first frame..