Page 1 of 1

random animation

PostPosted: Tue Mar 21, 2006 10:03 pm
by frodo
I want to have a background that has two animations, a hill and a forest.
When I create my background actor, I want to choose randomly between the forest and the hill.
THANKS A BUNCH!

PostPosted: Wed Mar 22, 2006 3:27 am
by Fuzzy
Is the background actor tiled infinitely? If so, It may not be possible.

If you are placing the background tiles by hand, then in the create actor event, do this

pick a random number... then use that to set the animation in script editor

Code: Select all
factor = rand(amount);

switch(factor)
{
case 0: { do something here}
case 1: { do something else }
case 2: { factor = 3;}
case 3: { will cause this line to activate}
case x: { dont forget to include a case for each possible value}
}

PostPosted: Wed Mar 22, 2006 3:34 am
by frodo
sorry, be more specific!

PostPosted: Wed Mar 22, 2006 4:11 am
by Fuzzy
ok. how are you placing the actors?

PostPosted: Wed Mar 22, 2006 4:14 am
by frodo
I just have one actor, with my two animations. I want to have a random animation come up when the actor is created.

PostPosted: Wed Mar 22, 2006 4:35 am
by Fuzzy
Do you want them to all be the same at the same time, or all different?

That is, is the animation a full scene, or is it just a hill or tree that your want to use to build a scene with, and are you using the infinite setting for tiling?

PostPosted: Wed Mar 22, 2006 2:03 pm
by frodo
I have just one actor... no clones, no tiles, no infinite. I just want my actor to have a random animation (still picture) when it is created. like, sometimes the hill, and sometimes the forest.
Thanks

PostPosted: Wed Mar 22, 2006 6:21 pm
by Novice
On create actor
Code: Select all
int i;
i= round(rand(1));
if (i==0) Change Animation (Hils.......);
else if (i==1) Change Animation (Trees.....);


I think this is what you need.

PostPosted: Wed Mar 22, 2006 6:49 pm
by makslane

PostPosted: Wed Mar 22, 2006 7:19 pm
by frodo
THANKS NOVICE! You're great!

PostPosted: Sat Apr 08, 2006 6:12 am
by DilloDude
You could also use
Code: Select all
ChangeAnimation("Event Actor", getAnimName(round(rand(numberofanimations))), FORWARD);