Page 1 of 1

Having Trouble with cloned enemy actors...

PostPosted: Fri Dec 09, 2011 6:30 pm
by RippeR7420
So, I have my enemy set up like this;

Enemy->Create->Script->

Code: Select all
Enemy.textNumber=3;


Enemy->Draw->Script->

Code: Select all
if(Enemy.textNumber==0)
{
DestroyActor"Enemy";
}


and on my Character;

Collision->AnySide->Enemy->Script->

Code: Select all
Enemy.textNumber=Enemy.textNumber-1;


now my problem is, if I clone the enemy, every Enemy dies when the textNumber=0;...

sorta like this I guess;

Code: Select all
EventActor.textNumber=3;

if(EventActor.textNumber==0)
{
DestroyActor"EventActor";
}


Is there a way I can set up a form of "EventActor" only on the Enemy that my Character is colliding with?
I've tried a few things, but nothing has worked yet...
+1 to whom who helps :)

Re: Having Trouble with cloned enemy actors...

PostPosted: Fri Dec 09, 2011 8:27 pm
by Hblade
Just remove "EventActor." XD All you need is "textNumber" instead of "EventActor.textNumber"
Code: Select all
textNumber=3;

if(textNumber==0)
{
DestroyActor("EventActor");
}

Re: Having Trouble with cloned enemy actors...

PostPosted: Fri Dec 09, 2011 10:43 pm
by RippeR7420
I tried that and it didn't work... :(

Re: Having Trouble with cloned enemy actors...

PostPosted: Fri Dec 09, 2011 10:46 pm
by RippeR7420
would I put both codes in the CreateActor Event?
Because I have it set up as just the;

textNumber=3;

in CreateActor, and the;

if(textNumber==0)
{
DestroyActor"Enemy"
}

.in DrawActor?..

Re: Having Trouble with cloned enemy actors...

PostPosted: Fri Dec 09, 2011 11:29 pm
by skydereign
So, when addressing the event actor's variables, don't append the actor's name before it.
Enemy -> Create Actor -> Script Editor
Code: Select all
textNumber=3; // this will set the event actor's textNumber to 3
Enemy.textNumber=3; // this will set the Enemy with the lowest cloneindex's textNumber to 3

So, when you want to access the event actor's variables just use the variable, since using the actor's name will access the lowest indexed actor.

Also a word of warning, you shouldn't use textNumber for actors that aren't text actors. Also, you shouldn't use textNumbers like that. textNumbers have been known to behave oddly when you use them like a normal variables. You should only use them for displaying text, like this.
text_actor -> Draw Actor -> Script Editor
Code: Select all
textNumber=score;


Now, another thing that Hblade corrected for you, but you haven't fixed is the DestroyActor. DestroyActor is a function, so you have to use the (), instead of what you were using DestroyActor"Enemy";.
Code: Select all
DestroyActor("Event Actor");

And like using Enemy.textNumber, you can't use DestroyActor("Enemy") as that will destroy all Enemy actors. It isn't what you call clone specific. You need to destroy the "Event Actor".

Re: Having Trouble with cloned enemy actors...

PostPosted: Sat Dec 10, 2011 12:40 am
by RippeR7420
@Sky: I know the DestroyActor Function... I was just quickly typing real quick haha.. and I am not even using Destroy Actor..

I tried to use a variable also, but when I clone the enemy the variable is cloned also...
How would I do what I am trying to do?

Re: Having Trouble with cloned enemy actors...

PostPosted: Sat Dec 10, 2011 12:47 am
by skydereign
Well what you're really doing is creating an hp system. So, don't use textNumber, create an actor variable called hp. Since the collision event belongs to the player, and collides with the enemy, you can use collide.hp to access the colliding Enemy actor's hp.
Enemy -> Create Actor -> Script Editor
Code: Select all
hp=3;

Player -> Collision with Any Side of Enemy -> Script Editor
Code: Select all
collide.hp--;

And last you have your DestroyActor check in the Enemy's draw actor event, though you could put it in the collision if you wanted.
Enemy -> Draw Actor -> Script Editor
Code: Select all
if(hp==0)
{
    DestroyActor("Event Actor");
}


That's pretty much what you had, but you were using textNumber, and you didn't use collide.var.

Re: Having Trouble with cloned enemy actors...

PostPosted: Sat Dec 10, 2011 3:31 pm
by RippeR7420
Ahh! Sky you're a genius!! haha, I forgot I had to make my variable an "Actor" variable and not a "Global" haha.
Thank you! +1!