How do I PICK RANDOM ANIMATION?

Get help using Construct 2

Post » Thu May 11, 2017 2:12 pm

I created a SPRITE. In it I have different ANIMATIONS: Animation1, Animation2, - different frames - etc.

I would like to:

Bullet OnCollision with SPRITE > Play Animations (contained in ITEM) Randomly.

I don't know if that's clear but the fact of the matter is: I already have this going like SET ANIMATION TO ("Animation1, Animation2, Animation3")

I tried quoting animations individually and all but it still aint working.

HELP :)
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

Post » Thu May 11, 2017 2:20 pm

kiko2015 wrote:I created a SPRITE. In it I have different ANIMATIONS: Animation1, Animation2, - different frames - etc.

I would like to:

Bullet OnCollision with SPRITE > Play Animations (contained in ITEM) Randomly.

I don't know if that's clear but the fact of the matter is: I already have this going like SET ANIMATION TO ("Animation1, Animation2, Animation3")

I tried quoting animations individually and all but it still aint working.

HELP :)


Use the choose() function.

choose("Animation1", "Animation2", "Animation3")
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
80
S
29
G
94
Posts: 1,153
Reputation: 63,167

Post » Thu May 11, 2017 4:19 pm

chadorireborn wrote:
kiko2015 wrote:I created a SPRITE. In it I have different ANIMATIONS: Animation1, Animation2, - different frames - etc.

I would like to:

Bullet OnCollision with SPRITE > Play Animations (contained in ITEM) Randomly.

I don't know if that's clear but the fact of the matter is: I already have this going like SET ANIMATION TO ("Animation1, Animation2, Animation3")

I tried quoting animations individually and all but it still aint working.

HELP :)



Use the choose() function.

choose("Animation1", "Animation2", "Animation3")



Is this the simpliest way?
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

Post » Thu May 11, 2017 4:21 pm

@Kiko2015 What I would do is have a variable for the random animation then in the event sheet have each animation set to a number on a viable then you just change the variable to a random number.
Image
B
44
S
22
G
13
Posts: 352
Reputation: 11,503

Post » Thu May 11, 2017 5:04 pm

try

Image

Sprite set animation
Code: Select all
"Animation"&str(int(random(8))+1)
B
67
S
24
G
7
Posts: 1,519
Reputation: 11,104

Post » Fri May 12, 2017 2:59 am

LaurenceBedford wrote:@Kiko2015 What I would do is have a variable for the random animation then in the event sheet have each animation set to a number on a viable then you just change the variable to a random number.



Thank you. Unfortunately, none of the answers helped me. But I ould like to know if we have exchanged emails before. I cant find your email. I would like to help ypu.
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

Post » Fri May 12, 2017 6:07 am

@Kiko2015 Sorry for that you are correct the email is wrong here's the right email address [email protected] .com
Image
B
44
S
22
G
13
Posts: 352
Reputation: 11,503

Post » Fri May 12, 2017 10:03 am

You could try this , under set animation

I have used this before, it works.

tokenat("animation1|animation2|animation3|animation4|animation5|animation6", int(random(6)),"|")


Of course @Anonnymitet has the Easiest method with Choose
Last edited by sizcoz on Fri May 12, 2017 11:00 am, edited 1 time in total.
Super Soccer Skills\Bushy Ball\Sticky Web\Snake
Image ImageImageImage
During the gold rush it was a good time to be in the pick and shovel business
B
60
S
20
G
3
Posts: 283
Reputation: 7,978

Post » Fri May 12, 2017 10:18 am

I don't understand how the above answers could not help you? That is exactly how you do it.

on bullet collision with player --> set animation to --> choose("animation1","animation2","animation3")

Remember to add "" around every animation name like the example above.

So in the text field on the play animation action you write exactly this:

Code: Select all
choose("animation1","animation2","animation3")


Except change the name of the animations to the ones you want to use
B
63
S
26
G
16
Posts: 816
Reputation: 14,573

Post » Sun May 14, 2017 6:04 am

Anonnymitet wrote:I don't understand how the above answers could not help you? That is exactly how you do it.

on bullet collision with player --> set animation to --> choose("animation1","animation2","animation3")

Remember to add "" around every animation name like the example above.

So in the text field on the play animation action you write exactly this:

Code: Select all
choose("animation1","animation2","animation3")


Except change the name of the animations to the ones you want to use


Thank you. It DOES work, Myy bad!!!! Thank you so much!!!

:)
B
19
S
4
G
2
Posts: 97
Reputation: 2,244


Return to How do I....?

Who is online

Users browsing this forum: saour and 8 guests