Delete an actor with no rules inside it.

dshoedshoe Member Posts: 62
edited November -1 in Working with GS (Mac)
Is it possible to destroy an actor with no rules inside of it? I need to have as little code inside an actor as possible. What would be the easiest way to destroy an actor using code from outside the actor that is being destroyed?

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    When game.attribute is true
    --Destroy
  • dshoedshoe Member Posts: 62
    If I have a lot of the same actors down and I only want to delete one then that would delete all of them.
  • rlehmrlehm Member Posts: 320
    Give each a separate game attribute
  • dshoedshoe Member Posts: 62
    calvin9403 said:
    no, use actor ID, is faster

    What is an actor ID? I dont see it under an actors attributes.
    rlehm said:
    Give each a separate game attribute

    That will not work. I can have up to 500 or so of the same actors on the screen at one time.
  • rlehmrlehm Member Posts: 320
    Then you'll need if collide with main actor touch whatever, destroy, in all 500
  • RHRH Member Posts: 1,079
    I think Calvin is talking about doing something like this:

    create a global attribute, say game.ActorID and a local attribute on the actor, say self.ID

    on the actor put -
    change attribute game.ActorID to ActorID+1 (you don't need this if you edit each instance separately but this removes the need for that and allows your to spawn new instances of the actor)
    and underneath that put -
    change attribute self.ID to game.ActorID
    and when self.ID=game.whichID - destroy

    If you spawn new instances of the actor during gameplay you will need to create another global attribute called game.whichID or something

    On another actor, when you want to destroy the specific instance create a rule
    when what ever happens to destroy it
    change attribute game.whichID to the id of the one that you want to destroy or random(1,game.ActorID)

    By the way, why on earth would you have an actor with no rules in it? An image?

    And good luck with 500+ actors in one scene!

    Oh and answering the very first question... no. There is probably also an easier way to destroy it but this is how I would destroy a specific instance of an actor from another.
  • dshoedshoe Member Posts: 62
    I am going to keep trying to work on this, but for now I think I will just have an option to delete all the actors and just reset the scene. I hope I can show all you guys my project soon enough!
  • rlehmrlehm Member Posts: 320
    Look forward to seeing it.
Sign In or Register to comment.