[Solved] randomly play different animations

Get help using Construct 2

Post » Wed Jan 08, 2014 7:27 pm

I have this animal that I want to blink it's eyes but only randomly. I'd like it to be seamless so it seems like maybe if there were some "on completion of animation" event i could randomly pick a number after each the main idle animation complete and if the number is a certain number, then it would play that other animation and when that completes, random again.. over and over.

I just don't see how i can achieve that looking at an objects animation options. Any suggestions?


Thanks!
Calebpart12studios2014-01-10 04:16:58
B
59
S
9
G
1
Posts: 942
Reputation: 6,553

Post » Wed Jan 08, 2014 7:33 pm

On animation ended (animation name) set variable1 to Random()

If Variable1 = whatever start animation2

On animation2 ended start animation 1
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,583

Post » Wed Jan 08, 2014 7:35 pm

Take the eyes out of the sprite. and have it pinned to your main character.

Then use an event to animate eyes independently.

Go look here for some inspiration:
http://www.scirra.com/forum/tutorial-camera-fx-limbo-look_topic40427.html
B
22
S
7
G
4
Posts: 154
Reputation: 3,709

Post » Wed Jan 08, 2014 9:57 pm

I use the variable method for my game. The main character in my game can strike in 4 directions, but a random animation is played every time to keep things dynamic. For every strike a given variable gets assigned a random number between 1-10.

To use this variable with your animations, you must first name your animations accordingly. The animations are for instance called LeftHit_1, LeftHit_2 etc.

The string to trigger this is: "LeftHit_"&VariableWithMagicNumber


Hope this helps.Tinimations2014-01-08 21:57:25
B
33
S
10
Posts: 376
Reputation: 3,193

Post » Wed Jan 08, 2014 10:09 pm

Instead of using a variable number you could also use:

choose("blinkfast","blinkleft","blinkslow")

that way you can just use the animationnames you want.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 09, 2014 3:29 pm

oh wow that's so cool that you can just plug in objects names like that @LittleStain! i love it.

@bluephase.. i don't know if I understand how to do that "on end". where would I access that event? I don't recall seeing that anywhere I've been in but maybe i'm looking in the wrong place?

thanks!
Caleb
B
59
S
9
G
1
Posts: 942
Reputation: 6,553

Post » Thu Jan 09, 2014 3:34 pm

I'm not sure objectnames would work as expected.
Strings and numbers work great.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 09, 2014 8:43 pm

Hi @part12studios,

go to the animation category of events in your object and look for "On Finished". I guess that is what bluephase ment :)
B
22
S
7
G
4
Posts: 154
Reputation: 3,709

Post » Fri Jan 10, 2014 4:15 am

ok awesome that worked great! I get it now and got it working similar to how you suggested! Yea I just hadn't noticed the animation options until you clearly pointed them out. Thanks a bunch for your help on this. This opens up a lot of other fun possibilities :)
B
59
S
9
G
1
Posts: 942
Reputation: 6,553


Return to How do I....?

Who is online

Users browsing this forum: David181, Norafaithrainbow and 33 guests