Forum

Animation - callback loop

19 March 2018 16:09
Hi, im'trying to fire a second animation when the first ends.


exports.applyAnimationAndPlay = function ( object, animation, callback )
{
var objectid = m_scenes.get_object_by_name( object, m_scenes.DATA_ID_ALL );

m_anim.apply( objectid, animation );
m_anim.set_behavior( objectid, 'AB_FINISH_STOP' );
m_anim.play( objectid, callback );
}

blend4w.applyAnimationAndPlay('ob1', 'animation1', blend4w.applyAnimationAndPlay('obj2', 'animation2') );

The animation fired in the callback loops infinitely.

Any idea about that?

Thanks in advance

Best regards

Matteo
22 March 2018 00:28
Hello! And welcome to our forum!
Could you attach the project to save our time?
Alexander (Blend4Web Team)
twitter
23 March 2018 14:25
Hi, thanks!

Sorry but the project is huge and requires our backend modules.

:(
24 March 2018 18:30
The mistake is here:
blend4w.applyAnimationAndPlay('ob1', 'animation1', blend4w.applyAnimationAndPlay('obj2', 'animation2') );

You should pass function but you are passing the result of blend4w.applyAnimationAndPlay('obj2', 'animation2') call.
The correct line is:
blend4w.applyAnimationAndPlay('ob1', 'animation1', function() {blend4w.applyAnimationAndPlay('obj2', 'animation2') });


Example project is attached.
Alexander (Blend4Web Team)
twitter
 
Please register or log in to leave a reply.