Jump to content

Fire "CombineAction" by "if" condition


Recommended Posts

Hi everyone and merry Christmas.


I need to play a group of animations when an "if" condition happens. I tried with this:

if(cond > 1){    elevador.actionManager = new BABYLON.ActionManager(scene);    elevador.actionManager.registerAction(    new BABYLON.CombineAction(BABYLON.ActionManager.NothingTrigger,       [       new BABYLON.PlayAnimationAction(BABYLON.ActionManager.NothingTrigger, elevador, 0, 288, 0),       new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.NothingTrigger, function () {           scene.registerBeforeRender(function () {              if(camera.position.y < 102){                  camera.position.y += 1;              }           });       }),       new BABYLON.PlaySoundAction(BABYLON.ActionManager.NothingTrigger, sonidoElevador)      ])    );}

But this dont work. What changes can I do to achieve it?



Link to comment
Share on other sites

If cond > 1, looks like the action is registered.  The point of an action registration is to declare what should happen in advance.  You could just do it, since you do not want do it right then.

if(cond > 1){    scene.registerBeforeRender(function () {        if(camera.position.y < 102){            camera.position.y += 1;        }    });    sonidoElevador.play();}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...