Jump to content

Sync animations to sound


shabbar
 Share

Recommended Posts

I want to sync animation with sound , for example i have a character and i want to animate his mouth only when narration is palying , and mouth should be shut when there is gapes in the narrations 

 

what i am doing is i am using currentTime sound property to check if sound reaches certain position in the update function but it is not working for me as update function called with certain interval and when this function called sound time is less or more then what i am testing in the if condition , that is why this condition never full fill , 

 

and if i set if condition as >= then the commands keep executing again and again as condition remain full fill for the rest of the sound time  

 

please let me know how i can synch animation with sound 

  update: function () {        if (this.narration.currentTime == 1380) {            this.mouth.animations.stop();        }        if (this.narration.currentTime == 11879) {            this.mouth.animations.play('talking', 25, true, false);        }         }
Link to comment
Share on other sites

Hello,

 

It depends of the precision & complexity of what you want to achieve.

 

The simplest solution would be to use a timer instead of the update function.

 

Example : 

var timer = game.time.create(false);var durationBeforeBlank = 1380;timer.add(durationBeforeBlank, this.onNarrationComplete, this);timer.start();

Then you can stop the mouth animation in this.onNarrationComplete.

 

As an advice, I would create a specific manager to handle this lip sync behaviour, which for example may load a json containing durations and delays between animations.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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