Page 1 of 1

Clones from one key down event?

PostPosted: Sun May 22, 2011 5:16 pm
by BloodRedDragon
I have a key down event that creates a new actor after the old actor has been destroyed. It's basically a function where the player can try again after he/she dies. But I am getting two of the same actor when I do this; this is detrimental to the frame rate. No repeat, only one actor and one key!! if the bug is unsolvable, is there a line of code that checks if the game only has one of a certain actor?

Re: Clones from one key down event?

PostPosted: Sun May 22, 2011 5:26 pm
by Hblade
What I do is: When the character "dies" the actor doesn't actually get destroyed. Instead, his movement capabilities and other events are disabled by a variable (if ENABLED==true, yada yada) I just make Enabled false and when I respawn, make enabled true again

Re: Clones from one key down event?

PostPosted: Sun May 22, 2011 6:26 pm
by lcl
You can check the number of some actors clones this way:
Code: Select all
if (ActorCount("player")==0)
{
    //create the actor here
}

But that bug sounds weird.
Do you reload the level also?
If you do and you load it with loadGame(), there will be the loaded levels player actor and the one created with keydown event.

Re: Clones from one key down event?

PostPosted: Mon May 23, 2011 10:24 pm
by BloodRedDragon
Fixed it by creating Key Down > Script Editor > Load Game, where it loads itself, causing the level to reset. Works fine.
Thanks lcl!

Re: Clones from one key down event?

PostPosted: Tue May 24, 2011 12:03 am
by rykein
sounds like you either didnt destroy an actor or have it set to repeat. but i guess load game works for you. when your game gets big its going to be annoying to load it everytime.