Page 1 of 1

When "collide" is destroyed

PostPosted: Sun Sep 15, 2013 11:24 pm
by SkenderBeu
Hello,

I'm having a problem with moveTo when a collider is destroyed. I'll explain the situation.

I'm telling a soldier to moveTo(1,1) and when he collides with the "enemy", I'm telling him to moveTo(x, y)(stop), fight and than kill the enemy,
than I'm telling him to moveTo(1,1). This works fine.

But when 2 soldiers are told to moveTo(1,1) and if they collide with the enemy they fight him and kill him only one is continuing to point(1,1).(with my code)

Soldier -> onCreate -> moveTo(1,1);
Soldier -> onCollide -> Script,

Code: Select all
int axeman; // 1 - alive, 0 - dead, axeman(enemy)

//DestroyTimer("axeman_rate");
//CreateTimer("Event Actor", "axeman_rate", 500);

axeman = collide.isAlive;

if(axeman == 1)// is alive
    {
     MoveTo("Event Actor", x, y, 1.000000, "Game Center", "");//stop
     collide.HP = collide.HP - Attack;//fight
    }
else// not alive
    {
     MoveTo("Event Actor", 320.000000, 170.000000, 4.000000, "Game Center", "wall");//continue
    }
if(collide.HP <= 0)//killed
    {
     axeman = 0; // dead
     MoveTo("Event Actor", 320.000000, 170.000000, 4.000000, "Game Center", "wall");//continue
    }


This is the problem when collide is destroyed and the soldier has already stopped than there is no way to continue(not in my code),

When I tried to check if soldier is colliding with drawActor game started to act weird

I would appreciate any help or suggestions on how to implement this, this is a game based on tower defense but here you can send soldiers to fight in the path

Re: When "collide" is destroyed

PostPosted: Mon Sep 16, 2013 12:49 am
by skydereign
You could do several things. One is to have in draw the move back to (1,1) if the actor isn't attacking or moving. Another way would be store the cloneindex of the enemy it is attacking, that way you can check in draw if the actor is dead or not. You'd need to use a getclone2 function for this though.