Enemy Life Attribute...could be a problem?

DaneVincentDaneVincent Member Posts: 7
edited July 2012 in Working with GS (Mac)
Hi Guys

I'm new to GS and Have been cramming Tutorials for about a week, i have just recently completed the George Collins Arcade Shoot em up Tutorial and have a question about the enemy health Attribute.

ie, you create a new attribute in Game lets say "Enemy Health" and assign a value of 100 etc.
now in the tutorial if your bullet hits the enemy it gets destroyed and the attribute is changed

Change Attribute / Game.Emeny Health - 50 "therefor meaning i essentially have 50hp left.

and then later on you have another statement that says if Enemy Health is =< 0, the You won Game Screen pops up.

perfect.

Now, if i have multiple instances of Enemy running across the stage and i manage to "destroy" one enemy by reducing
Game.Enemy Health to Zero rather than calling up the You Won Screen, will it affect the other Enemies on the Screen Globally, and destroy them all? or does it just affect the Instance?

I hope my explanation is understandable.

Thanks

Dane

Best Answer

  • developer6810developer6810 Posts: 139
    Accepted Answer
    If you don't want the you won screen to pop up, you should edit the instance of each enemy (even though there is a lock on it) to when enemy.health =< 0 destroy actor. You should then have a boss that doesn't come until the end by using a timer and saying after ... seconds spawn actor Boss and then when boss.health =< 0 destroy actor and change scene to you won.

    Hope this helps!

Answers

  • DaneVincentDaneVincent Member Posts: 7
    Thanks for the Reply Developer6810

    sorry i think i got a bit side tracked with my explanation.

    Ok lets say I have 5 Enemies on the Screen in a straight line and i kill one by reducing the Enemy.Health Attribute i created to 0,

    Now the Actor "Prototype" "Enemy" has When Enemy.Health =< 0 Destroy, therefore all the instances inherit the same behavior/Rule.

    so in my mind, if i destroy one actor "Instance" "Enemy" by reducing the Attribute Enemy.Health to 0 the other Enemy actors on the screen should be destroyed as well, therefor acting Globally. or does Game Salad Interpret Each Instance Individually Regardless of the fact that they share the same Attribute Enemy.Health

    Sorry I would Test it but i don't have enough time, thus the questions.

    Thanks again :D
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @DaneVincent, the key here is to understand the different between game attributes and actor attributes. The answer to your question is that if you have each enemy check game.EnemyHealth and game.EnemyHealth reaches zero, then they will all be destroyed at the same time since they are all "watching" the same attribute value. Instead, use an actor attribute self.Health on each enemy. Have the enemy's rule set to When attribute self.Health <=0 Destroy this actor.

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

  • DaneVincentDaneVincent Member Posts: 7
    Thanks Tatiang, i didn't know i could add attributes to Actor Prototypes ie Self.Health etc... sometimes the answer is so simple i could kick myself.

    thanks all for the reply's
  • InLaNocheInLaNoche Member Posts: 20
    I thought the same thing as well when going through the Windows GSC documentation. They talk about not being able to access other actors attributes, but the collission detection can be seen from either the bullet or the target. The first example they give in this documentation is not a good one, since they tie the 1 enemy's heath to game.EnemyHealth...
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Game-level attributes are used to communicate between actors, but it's not the only way. If you have two actors on a scene and you unlock one, you can then view the other actor's attributes using the Scene submenu. This alleviates the need for an extra attribute, and is especially helpful in cases where you want to constrain one actor's attribute to another actor's attribute without doing two constrains (constrain game.ActorAPosition to self.ActorAPosition & constrain self.ActorBPosition to game.ActorAPosition becomes constrain self.ActorBPosition to Current Scene.layers.[Background].ActorA.Position.X).

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

Sign In or Register to comment.