How To Only Have One Actor By Deleting the Old Actor After Another One Placed?

iTechMan427iTechMan427 Member Posts: 39
edited August 2013 in Working with GS (Mac)
I would like to be able to place an actor "Player 1" with touch (I already know how to do that.) and then when I place another "Player 1" actor, the last actor will be deleted. I want to do this so I can only be allowed to place one. Any suggestions?

Best Answer

  • ericzingelerericzingeler Posts: 334
    Accepted Answer
    I would suggest that you identify your spawned actors so that they are unique. Once that is done, a simple rule is all it takes. Like so:

    Game Attribute:

    activeID (index) = 0

    Spawned Actor Attribute:

    myID (index) = 0

    Inside spawned actor:

    Very first behavior outside of any rules:

    Change attribute game.activeID To: game.activeID + 1

    Change attribute self.myID To: game.activeID

    A rule to destroy actor (placed after the above):

    If self.myID not equal To: game.activeID

    destroy

Answers

  • CatGoneCrazyCatGoneCrazy Member, PRO Posts: 90
    Make a global boolean attribute. When a new actor is placed, change it to true from within the new actor. Have a self timer that gives it a second of immunity or similar then say 'if (that global boolean) is true, destroy actor and change global boolean to false. That way, old actors will be deleted, new ones reset the boolean. Hope that makes sense.
  • iTechMan427iTechMan427 Member Posts: 39
    edited August 2013
    When you say "a second of immunity" do you mean setting a timer to "for 1 seconds change the global boolean to false"? And when I place another "Player 1" actor won't is just start the timer on the old actor? I'm still a little confused.
  • iTechMan427iTechMan427 Member Posts: 39
    I figured out another way to do it with "move to". Thanks for your help anyways.
Sign In or Register to comment.