Destroy spawned actor in sequence

Hi all GS Gurus out there, i am facing a problem of getting the spawned instance to be destroy according to sequence.
I created :
1) a spawner to spawn an enemy every 3 seconds.
2) an button with the rule when is pressed, destroy the enemy according to sequence.
Example: enemy no. 1, enemy no. 2 , enemy no. 3 ...and so on being spawned every 3 second
when the button is pressed, then enemy no.1 will be destroyed and then press again, enemy no. 2 is destroyed and so on...

Can any GS Gurus share with me how should i do that? I have been searching the forum for quite sometime....

Thanks in advance for the support and help.

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2014

    Hi @Game_AppAd Off the top of my head, but should work:

    Make an integer self attribute in your Prototype actor that's spawned; let's call it OrderNum.
    Make a scene attribute called DestryNum.
    Make a scene attribute called ActualDest

    Add to the Rules in your spawner actor :

    Change scene.DestroyNum to DestroyNum + 1

    Now add into your Prototype actor (the spawned one):

    Change Attribute OrderNum to DestroyNum

    Rule: When OrderNum = ActualDest
    Destroy
    

    Now in your button, put:

    Change Attribute ActualDest to ActualDest+1

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • Game_AppAdGame_AppAd Member Posts: 10

    Hi Gyroscope,

    Awesome!The logic works wonderfully. Thank you very much. By using scene attribute, will it use up memory? As my game is like those endless run game style, after spawning actor for a long periods, would it be any performance issue?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited November 2014

    @gyroscope is suggesting that you use an attribute to keep track of the actor count. It wont matter whether that attribute's value is 5 or 10,000. It's still just a single attribute which uses next to no memory at all.

    I would recommend making the DestroyNum a game attribute though because accessing a scene attribute from a spawned actor would be quite tricky (impossible?).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.