Make an actor randomly select an animation?

Talk about making games.

Make an actor randomly select an animation?

Postby CrimsonTheDarkBat » Fri Jun 15, 2012 10:31 am

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
Sonic Velocity Development Thread --> http://game-editor.com/forum/viewtopic.php?f=4&t=11461

Completed Games:
Sonic: War of the Emeralds
Sonic: Empire of Nightmares
Sonic.EXE - The Game
Alice: Crimson Omen
Epsilon 27
User avatar
CrimsonTheDarkBat
 
Posts: 223
Joined: Fri Mar 21, 2008 10:54 am
Score: 20 Give a positive score

Re: Make an actor randomly select an animation?

Postby skydereign » Fri Jun 15, 2012 3:54 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Make an actor randomly select an animation?

Postby lcl » Sat Jun 16, 2012 12:08 pm

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
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Make an actor randomly select an animation?

Postby CrimsonTheDarkBat » Sun Jun 17, 2012 9:22 am

Thanks very much Skydereign and lcl - problem solved straight away. :D
Sonic Velocity Development Thread --> http://game-editor.com/forum/viewtopic.php?f=4&t=11461

Completed Games:
Sonic: War of the Emeralds
Sonic: Empire of Nightmares
Sonic.EXE - The Game
Alice: Crimson Omen
Epsilon 27
User avatar
CrimsonTheDarkBat
 
Posts: 223
Joined: Fri Mar 21, 2008 10:54 am
Score: 20 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest