how can i make an actor have a rand om animation?
and also... how can i make items randomly appear on a random part of the stage, and only when ur in a battle (not just in the menu)
int n;
n = rand(*put how many different actions you want here* 2)
if(n==0)Action;//Always start with zero for 1\\
if(n==1)Action;
int anim = rand(nAnims);//change nAnimns to the number of animations you want to choose from
//if you want to choose between all the anims, or just the first few, you can use this:
ChangeAnimation("Event Actr", getAnimName(anim), FORWARD);
//or if you want the last few, or a group in the middle, use this:
ChangeAnimation("Event Actr", getAnimName(anim + value), FORWARD);//change value to the frame number of the first frame you're using
//if you want to choose from a collection of animations, not all together, yuo have to do it manually:
switch(anim)
{
case 0: ChangeAnimation("Event Actor", "someAnimation", FORWARD); break;
case 1: ChangeAnimation("Event Actor", "someOtherAnimation", FORWARD); break;
case 2: ChangeAnimation("Event Actor", "thisHereAnimation", STOPPED); break;
...
}
supa-tails wrote:How do I make an animation choose randomly at the create actor? For example, right when an actor is created it randomly chooses 1 out of 10 animations and stays that way.
animindex=rand(10);
int random = rand(2);
switch (random)
{
case 0:
//ChangeAnimation to actor's first animation
break;
case 1:
//ChangeAnimation to actor's second
break;
}
int RAND = rand(2);
switch (RAND)
{
case 0:
ChangeAnimation("Event Actor", "Bite", FORWARD;
ChangeAnimation("Collide Actor", "Jump", FORWARD;
break;
case 1:
ChangeAnimation("Event Actor", "Scratch", FORWARD;
ChangeAnimation("Collide Actor", "Block", FORWARD;
break;
}
Users browsing this forum: No registered users and 1 guest