Page 1 of 1

Having some real problems...

PostPosted: Mon Mar 05, 2012 12:32 am
by RippeR7420
I have my enemy set up so when he is facing different directions, His death animation will be different. Now, I didn't have a problem until I gave him life(ENEMYLIFE[actor variable]).
here is part of my code where I think the problem is;

Code: Select all
if(ENEMYLIFE<=0)
{
    if(ENEMYDIR==1)
    {
           ChangeAnimation("Event Actor", "Knight1death2_left", FORWARD);
           EventDisable("Event Actor", EVENTTIMER);
    }
 
    else
 
    if(ENEMYDIR==0)
    {
        ChangeAnimation("Event Actor", "Knight1death1_right", FORWARD);
        EventDisable("Event Actor", EVENTTIMER);
    }
}


I have it set up as, ENEMYDIR=1; is facing left. and ENEMYDIR=0; is facing right.
when ever he dies, it will only act on the first one(if(ENEMYDIR==1))...

any help would be GREATLY aprreciated.. :)

+1 Also

Re: Having some real problems...

PostPosted: Mon Mar 05, 2012 12:43 am
by skydereign
So ENEMYDIR is an actor variable? You should structure your code like this instead of what you have, because it be ambiguous what you meant (else if looks different from else followed by an if).
Code: Select all
if(ENEMYLIFE<=0)
{
    if(ENEMYDIR==1)
    {
           ChangeAnimation("Event Actor", "Knight1death2_left", FORWARD);
           EventDisable("Event Actor", EVENTTIMER);
    }
    else if(ENEMYDIR==0)
    {
        ChangeAnimation("Event Actor", "Knight1death1_right", FORWARD);
        EventDisable("Event Actor", EVENTTIMER);
    }
}

Do you know that ENEMYDIR is ever being set to 0?

Re: Having some real problems...

PostPosted: Mon Mar 05, 2012 1:13 am
by RippeR7420
do you mean put "else" next to "if", instead of spacing them?

and yeah, I have my enemy code set up like this;

Enemy->Collision->anyside of EnemyChangeDir(WireFrameRegion)->Script->

Code: Select all
if(ENEMYDIR==1)
{
    ENEMYDIR=0;
}

else

if(ENEMYDIR==0)
{
    ENEMYDIR=1;
}





then in the Enemies draw actor, I have it set up like this;

Code: Select all
if(ENEMYDIR==1)
{
    ChangeAnimation("Event Actor", "Knight1Run_left0001", NO_CHANGE);
    x-=2;
}

else

if(ENEMYDIR==0)
{
    ChangeAnimation("Event Actor", "Knight1Run_right0001", NO_CHANGE);
    x+=2;
}



So I have no idea why it isn't working...

Re: Having some real problems...

PostPosted: Mon Mar 05, 2012 3:23 am
by skydereign
Yeah, you should put else with if, otherwise it isn't as obvious what you mean. For example...
Code: Select all
if(i==0)
{
    // a
}

else

if(i==1)
{
    // b
}
if(i==2)
{
    // c
}

With this, the spacing of the else makes it look like if i isn't 0, than the next two ifs are run. But in reality it executes as follows.
Code: Select all
if(i==0)
{
    // a
}
else if(i==1)
{
    // b
}


if(i==2) // notice this if statement always triggers
{
    // c
}


From what you've posted, your code seems solid. It would be easier to spot the problem if you upload some file showing it not working.

Re: Having some real problems...

PostPosted: Mon Mar 05, 2012 9:20 pm
by RippeR7420
Alright Sky, Here is my code for my enemy;

Enemy-> collision-> anySideOf Weapon-> Script->
Code: Select all
if(ENEMYDIR==1)
{
    ChangeAnimation("Event Actor", "Knight1hurt_left", FORWARD);
    EventDisable("Event Actor", EVENTANIMATION);
    CreateTimer("Event Actor", "Old Man Walk", 300);
    CreateActor("BLOODspikeball", "bloodNo1_right00010001", "Event Actor", "(none)", -5, 0, false);
 
}
else if(ENEMYDIR==0)
{
    ChangeAnimation("Event Actor", "Knight1hurt_right", FORWARD);
    EventDisable("Event Actor", EVENTANIMATION);
    CreateTimer("Event Actor", "Old Man Walk", 300);
    ENEMYDIR=1;
    CreateActor("BLOODspikeball", "bloodNo1_left00010001", "Event Actor", "(none)", 5,0, false);
 
 
}




ENEMYLIFE=ENEMYLIFE-2;


else if(ENEMYLIFE<=0)
{
    if(ENEMYDIR==1)
    {
        ChangeAnimation("Event Actor", "Knight1death1_left", FORWARD);
    }
 
    else if(ENEMYDIR==0)
    {
        ChangeAnimation("Event Actor", "Knight1death2_right", FORWARD);
    }
}


I'm pretty sure this is where I'm having problems at...

Re: Having some real problems...

PostPosted: Mon Mar 05, 2012 10:39 pm
by phyzix5761
From what I can see here the code looks pretty good but sometimes when I'm programming and I use "Event Actor" the code doesn't work properly. I'm not saying it will work, but try changing "Event Actor" to the actual name of the actor.

Re: Having some real problems...

PostPosted: Tue Mar 06, 2012 12:41 am
by RippeR7420
I would do that, but, then it would make all my Enemy Clones change animation also. so I need to use Event Actor.

Re: Having some real problems...

PostPosted: Tue Mar 06, 2012 1:44 am
by skydereign
I've found that specifying event actor is the most reliable method, as it bypasses gE's parsing problems in global code. But other than that, there is no difference between specifying the actor's clonename and "Event Actor". I can't see the problem from the code, and we could spend quite a while asking about your setup, so could you post a ged of the problem? If you don't want to release anything so anyone can see it you can send me a pm with a link to it.

Re: Having some real problems...

PostPosted: Tue Mar 06, 2012 2:40 am
by RippeR7420
I'll send you the file Sky.