When "collide" is destroyed

Non-platform specific questions.

When "collide" is destroyed

Postby SkenderBeu » Sun Sep 15, 2013 11:24 pm

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
SkenderBeu
 
Posts: 4
Joined: Tue Aug 13, 2013 7:24 pm
Score: 0 Give a positive score

Re: When "collide" is destroyed

Postby skydereign » Mon Sep 16, 2013 12:49 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron