how do i have many actors on the same screen using the same (health) attribute,dut die independently

hi i am making a game where there are many soldiers but then when they are in battle and one soldier dies, all of them die. I know why, it is because they are linked to the same attribute but if you have 500 soldiers on the same scene you are not going to make 500 attributes for all of them, and of course they are all cloned actors that are spawned randomly by a spawn-er.
thanks in advance :3

Comments

  • BBEnkBBEnk Member Posts: 1,764
    edited November 2013
    actors can have a self attribute, just open your actor look to the left should have a + and - sign to add them.
  • iZeeBoiZeeBo Member Posts: 8
    i did that and i have added my rules that are connected to it but now the problem is that it just deletes my actors as soon as they are spawned.
    here are my rules that i have added, just to see if im wrong.

    Actor recieves event/overlaps or collides/with actor of type/rest enemy (the test enemy that i have)

    then in that rule i have:
    change attribute: self.health/To: self.health-1

    then in order to kill the soldier i have a new rule with
    Attribute/ self.health/(>_)/0.0
    and then a destroy behavior.

    hope this helps a little
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Are you using the Replicate behavior to spawn 500 enemies? If so they will all act the same and will share the same attribute values.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited November 2013
    And is this correct? It says if greater than 0 destroy them

    Attribute/ self.health/(>_)/0.0
    and then a destroy behavior.

    Wouldn't this instantly destroy all of them?
  • iZeeBoiZeeBo Member Posts: 8
    i know that if they are the same actors and they have the same attribute attached to them they will all die at the same time but i want to know how to make so that they all die single. i don't want that they all die at the same time but one by one as that actor has no more health. and that 500 soldiers at the same time is just literally, it can also be less. it depends on how many soldiers you have.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited November 2013
    self attributes are independent to each copy. If it's not working then you've got problems in your code elsewhere.

    Looking at your example (except for the greater than bit) it looks like it should act correctly which is why I think something else is creating the problem you're experiencing.

    Unless of course you used replicate to create the hundreds of enemies, and if so I think that's your problem right there
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited November 2013
    You said it is deleting your spawned actors immediately. My guess is that you haven't set their self.health values yet and they are set to zero (the default).

    You would need to have change attribute self.health to 10 (or whatever value) at the top of the rule list. Or you can manually set it in the actor's attribute pane.

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

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Here's an example that shows that multiple copies of the same actor can all have different value self attributes.

    Every 0.5 seconds a pink/salmon enemy is spawned on the screen randomly and each shows it's health value. Tap the enemy to deduct 1 health point until it gets down to 0 which destroys it. It destroys that actor only, not all of them

  • iZeeBoiZeeBo Member Posts: 8
    thanks i have now solved the problem. it works problemlessly and everything goes as i wanted it to. Thanks for your help guys!
Sign In or Register to comment.