Clones from one key down event?

Non-platform specific questions.

Clones from one key down event?

Postby BloodRedDragon » Sun May 22, 2011 5:16 pm

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?
Current projects:
Techno-Tank Arena: on hold
Techno-Tank SuperPortal (working title): 0.1%
Bowels of Galaxies: 35% (was a bit too optimistic)
User avatar
BloodRedDragon
 
Posts: 123
Joined: Tue Jan 29, 2008 10:07 pm
Location: The Underworld
Score: 5 Give a positive score

Re: Clones from one key down event?

Postby Hblade » Sun May 22, 2011 5:26 pm

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Clones from one key down event?

Postby lcl » Sun May 22, 2011 6:26 pm

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.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Clones from one key down event?

Postby BloodRedDragon » Mon May 23, 2011 10:24 pm

Fixed it by creating Key Down > Script Editor > Load Game, where it loads itself, causing the level to reset. Works fine.
Thanks lcl!
Current projects:
Techno-Tank Arena: on hold
Techno-Tank SuperPortal (working title): 0.1%
Bowels of Galaxies: 35% (was a bit too optimistic)
User avatar
BloodRedDragon
 
Posts: 123
Joined: Tue Jan 29, 2008 10:07 pm
Location: The Underworld
Score: 5 Give a positive score

Re: Clones from one key down event?

Postby rykein » Tue May 24, 2011 12:03 am

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.
rykein
 
Posts: 63
Joined: Mon Jul 26, 2010 7:26 am
Score: 6 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest