Random animation number?

I have searched for this but… how to make computer to choose random animation from 30 to 32 when variable attack is -1 it is when the player is under attack.

i don’t know what are you talking about with :

You use variables as you want, like this we don’t what is the purpose.

For your animation problem, juste use this formula : 30 + Random(2) => this will return 30 or 31 or 32

this is what i mean

[code]event
Condition:
player is in collision with enemy
the object variable attack of enemy is = 1

Action:
do = -1 to the global variable dragonmanAttack[/code]

So you want to affect “30 + Random(2)” to number of animation when the “global variable dragonmanAttack= -1” ??

Umar i really would like to help you because you seem to be very motivated, but you should take your time to write clear demand :

is the formula “30 + Random(2)” answered your previous question, and if yes, what is the problem about checking dragonmanAttack== -1 ?

may be I am doing it wrong.
What i want is this.
I have three animation for when player is under attack. I want computer to choose one of these animation when player is under attack.
how to write event for this propose.

Make a variable object to your character “dragonman”, named for example “IsUnderAttack” ; change this variable value to 1 when is on attack (collision).

When dragonman.IsUnderAttack == 1 then
Do = 30 + Random(2) to number of naimtion of dragonman object

You already something really near in your code

If i create too many variables it will be really messy I already have a lot of global variables in my game for my main character. And events are a lot complex. Can’t i use a negative number.

It doesn’t seem to be working i have tested it. it start to choose random animation from 30 - 32 and cycles it keep choosing it.

You character doesn’t need to have all global variable, ofr IsUnderAttack you should use object variable : Use global vr only for value you want to keep when you change scene.

it start to choose random animation from 30 - 32 and cycles it keep choosing it.

you mean the animation is changing continuously ??? So add a “trigger once” condition.

I added trigger once too. and wanna use global variable for main character, it just feels easy. For other i either create scene or object variable depending on the situation. and lastly it isn’t just cycling between (30 - 32) it’s cycling between (1,30-32,29) 29 is not selected for anything yet. i am thing about making time a factor to chose a random value between 30 - 32. but don’t wanna write a long event.

If it was me, I would do something like this:

If variable PlayerHit > 0 then
– animation number of Player = PlayerHit
– PlayerHit = 0

That way, I give a random value to PlayerHit anywhere else in the code, and it launches the corresponding animation one time only.

But you will meet the issue of “how do I tell the code when to get back to normal animation?”
I would add this:
If variable PlayerHit > 0 && CurrentlyAnimated == 0 then
– animation number of Player = PlayerHit
– PlayerHit = 0
– CurrentlyAnimated = 1

If CurrentlyAnimated == 1 && animation image number of Player >= 5 && animation number of Player != 0 then
– CurrentlyAnimated = 0
– animation number of Player = 0

This way, when my animation has ended ( No5 or above), I tell the code it can launch another animation while returning to the default animation (0).