Page 1 of 1

creating actor,changing animation immediately - doesnt work?

PostPosted: Sat Jun 30, 2007 9:45 pm
by sonicfire
hi folks! :D

another little problem here that i cant fix and dont know why:

i have an "explosion"-actor. it holds 10 animations of little explosions. i assigned the first one to it.

now, i create this actor somewhere in a game when i hit a certain object. no problems so far. trouble starts here:

i use a simple
Code: Select all
temp = floor(rand(9));
if (temp = 0)
{
    ChangeAnimation("Event Actor", "bluexeplo1_", FORWARD);
}
if (temp = 1)
{
    ChangeAnimation("Event Actor", "bluexeplo2_", FORWARD);
}

(...) and so on ....


in the Actor Create-Event. So hopefully you get the picture.

The problem is however, it simply doesn´t change its animation. Am i thinking totally wrong? I though immediately after the actor has been created it should have "become" a new animation ... :(
Sadly, it always just plays the animation that i´ve selected in GE itself....

Fun thing is: I tried the same using Sounds (to play random explosion-sounds and this DOES work!

Can anybody enlighten me, please? :oops:

PostPosted: Sat Jun 30, 2007 9:49 pm
by sonicfire
Wait a minute ... could it be because of the "Event Actor"? :shock:
Since its only created ... um, does that cound as an event? I mean... damn, hard to explain in english :oops: :lol:

EDIT: The Creator-Actor that creates THIS explosion-actor is the Event Actor in this very moment?! Could that be my mistake?

PostPosted: Sat Jun 30, 2007 9:52 pm
by d-soldier
Try this in the create-actor script:

int n;
n=rand(30);
if (n<=10 && n>=0)
{
//INSERT CHANGEANIMATION SCRIPT HERE
}
if (n<=20 && n>=10)
{
//INSERT CHANGEANIMATION SCRIPT HERE
}
if (n<=31 && n>=20)
{
//INSERT CHANGEANIMATION SCRIPT HERE
}

Be sure that the actor has all these different animations you under it's ANIMATION drop-down button, and modify the "//INSERT" part to be a "CHANGEANIMATION SCRIPT" applying a different animation (animindex) for each of 'em. see if that works better then your other code.

PostPosted: Sat Jun 30, 2007 10:16 pm
by sonicfire
thanks again!
will give it a go! :)

PostPosted: Sat Jun 30, 2007 10:50 pm
by Kodo
sonicfire, there are problems with your conditional statements!

if (temp = 0)
{
ChangeAnimation("Event Actor", "bluexeplo1_", FORWARD);
}
if (temp = 1)
{


should be written

Code: Select all
if (temp == 0)
{
    ChangeAnimation("Event Actor", "bluexeplo1_", FORWARD);
}
if (temp == 1)
{

Note that == should be used when comparing values, = on its own just assigns the value. So what you are actually doing with your code is just assigning values and not testing them!

PostPosted: Sat Jun 30, 2007 11:32 pm
by sonicfire
Oops! :shock: I did it again :lol: Sorry for this! My fault, thanks very much!