Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: will_brett on February 06, 2013, 06:54:12 AM

Title: [SOLVED] Idle Animations: how to wait random amount of time
Post by: will_brett on February 06, 2013, 06:54:12 AM
Hey everyone.

i have made a simple blink animation using TK2d and now I want to make my character blink occasionally and randomly. How would I go about doing this? I suppose it doesn't have to be random, just not seem like the blink is on a constant loop where you can predict when it will blink if that makes sense.

thank you

WB
Title: Re: Idle Animations: how to wait random amount of time
Post by: will_brett on February 07, 2013, 07:17:29 AM
...BUMP...
Title: Re: Idle Animations: how to wait random amount of time
Post by: Andrew.Lukasik on February 07, 2013, 08:05:12 AM
You can make random delay with two simple actions:
With <Random Float> you generate specified random number and save it to variable.
Next you use that variable in delay field of <Wait> action. You loop states and it's done.
(animation must be set to play Once)
Title: Re: Idle Animations: how to wait random amount of time
Post by: will_brett on February 07, 2013, 08:12:59 AM
Thank you so much.

I will get on this right now.

All the best

Wb
Title: Re: Idle Animations: how to wait random amount of time
Post by: will_brett on February 07, 2013, 08:39:55 AM
I can't seem to get that to work.

What i did was have randomfloat under start that would generate a number between 5-30 and store result as a float names "Random_Number". I then created a new state with 'Wait' which looked for Random_Number, i left finished event blank and real time unchecked. Next I had a new state with TK2D Play Animation. Game object use Owner and clip name as "idle".

Where have I gone wrong? Im sure its something obvious. I also made sure animation is set to play once.

Thanks
Title: Re: Idle Animations: how to wait random amount of time
Post by: will_brett on February 07, 2013, 08:47:54 AM
I have also tried first state Random_float between 5-30 then having a wait state that uses Random_number for time and then loops back into the "Random_float" state

This also doesn't seem to do anything.

Title: Re: Idle Animations: how to wait random amount of time
Post by: Andrew.Lukasik on February 07, 2013, 10:29:22 AM
Oh it simply don't work now because in <Wait> you should fill Event field with relevant event. In this case shown above - named "Wait". Then it will proceed.

ps: In this "Random_Float" state, action that plays blink animation should fire finishing event as well.
Title: Re: Idle Animations: how to wait random amount of time
Post by: will_brett on February 07, 2013, 10:31:41 AM
Im not 100% clear what you mean. Do you mean fill the finish event with a "wait" event or that I have gotten the events set up wrong?

Thanks again
Title: Re: Idle Animations: how to wait random amount of time
Post by: Andrew.Lukasik on February 07, 2013, 10:46:21 AM
Take a look at this example (attachment below). After filling <Play Animation>'s target object and animation name fields then it should work and self-explain this process a bit.
Title: Re: Idle Animations: how to wait random amount of time
Post by: will_brett on February 07, 2013, 11:09:03 AM
Thank you that has made things much clearer and I can see the issue now.

In your example you have used a Play animation action, but I am using TK 2d for the animations so this will not work and if i use the TK 2D play animation action it doesn't have a finish event option
Title: Re: Idle Animations: how to wait random amount of time
Post by: will_brett on February 07, 2013, 11:15:41 AM
SOLVED!

All I needed to do was add TK 2d play animation with Events and not TK 2d play animation

Thank you for your help much appreciated