Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: nakker101 on October 22, 2016, 11:08:38 PM

Title: how to stop an actor's animation when music stops?
Post by: nakker101 on October 22, 2016, 11:08:38 PM
Hello to everybody.Many years passed since the last time I was trying to create a small game. I finaly decided to continue but I have a problem. In a scene there is a music player. I want "On take" to play a music,the 2D actor to go to a dance floor and start dancing and when the music stops I want the actor to stop dancing. The problem is that the music stops but the actor doesn't. The music file is an ogg file. The actor animation is a sprite with looping turn on because the animation is shorter than the music.What is the correct way for telling the game that when this particular music stops,it should stop the actor animation too? Thank you for your time.
Title: Re: how to stop an actor's animation when music stops?
Post by: s.belov on October 23, 2016, 04:49:50 AM
pseudo code:

Code: WME Script
  1. actor.GoTo(dance floor);
  2. any_object.PlaySound(music);
  3. actor.IdleAnimName = "dancing";
  4. while (any_object.IsSoundPlaying()) {
  5.    Sleep(1);
  6. }
  7. actor.IdleAnimName = "stop dancing";

Title: Re: how to stop an actor's animation when music stops?
Post by: nakker101 on October 28, 2016, 06:11:29 PM
Thank you s.belov for your answer. I have more questions if you don't mind.My actor is a 2D actor. Can the "actor.IdleAnimName" be used for a 2D actor too? If it can, when you write "actor.IdleAnimName = "dancing";" and "actor.IdleAnimName = "stop dancing";" this "dancing" and "stop dancing" what exactly is it?
Title: Re: how to stop an actor's animation when music stops?
Post by: eborr on October 29, 2016, 01:57:14 AM
"dancing " and "stop dancing" are animation sets - which can form part of an actor definition in the same way that "talk" "walk" and "turn" are.

If you want more on this I suggest you read the section on actors in the documentation that comes with the kit.

The other and perhaps easier way to kill an animation is actor.Reset();