Sync animations to sound

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) {  'talking', 25, true, false);        }         }

Share this post

Link to post
Share on other sites



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.

Share this post

Link to post
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.