Page 1 of 1

Make an actor randomly select an animation?

PostPosted: Fri Jun 15, 2012 10:31 am
by CrimsonTheDarkBat
Hey all, been a while since I've requested help.

On to business: basically, what I want is an actor to randomly select one of its animations when another actor tells it to ( eg; after one actor finishes it's animation, it then tells another actor in question to randomly pick an animation of its own.)
Script Editor I presume? I've tried coming up with some code but to no avail.

Any hope out there? :P

Re: Make an actor randomly select an animation?

PostPosted: Fri Jun 15, 2012 3:54 pm
by skydereign
Since getAnimName currently only retrieves the animation names of the current actor, I suggest using activation events. This code will change the event actor's animation to a random animation (5 possible animations).
Code: Select all
ChangeAnimation("Event Actor", getAnimName(floor(rand(5))), FORWARD);

That doesn't quite work in your case, but activation events are a way of making another (non-event actor) trigger code. It is easy enough to use, and very powerful. To send an event, you just use SendActivationEvent, with the only parameter being the clonename of the actor you want to send it to. Lastly you need to actually create the activation event, and put your animation code in there.

Re: Make an actor randomly select an animation?

PostPosted: Sat Jun 16, 2012 12:08 pm
by lcl
CrimsonTheDarkBat wrote:Script Editor I presume?

It always is the answer. This way everything can be well ordered.
Let me explain. With the use of script editor you can avoid a horrible amount of events which are for doing different things but at the same time. For example, without the use of script editor you will have MANY events for.. let's say level finish. One for showing some text that the level is completed and one for showing the score etc. Now here's where I suggest you to use script editor. Because all that can be done through GE built-in actions can be done in script editor, too.
Now you can combine ALL those same event actions in to ONE script. And this way you can find the events you need to edit without searching through 1000 events. I think you've had that problem because I've seen how complicated games you have created. :)
CrimsonTheDarkBat wrote:Any hope out there? :)

With this kind of problems, there always is hope! :D

Re: Make an actor randomly select an animation?

PostPosted: Sun Jun 17, 2012 9:22 am
by CrimsonTheDarkBat
Thanks very much Skydereign and lcl - problem solved straight away. :D