Spawn actor can change father attribute

First of all, sorry for bad english
Im new on gamesalad and following tutorials i'm starting to write something.

My problem:
I have n actors, for example only ACT1.
I need that each actor shot limit 3 shots at time.
So I add numFire attribute on ACT1 prototype.

RULES ACT1:
Each 0.5 sec, if numFire < 3 I make:
change attribute numFire = numFire +1
Spawn Actor (SHOT actor)


RULES SHOT actor:
At spawn: Move to direction 270 at speed 170, relative to scene

When Attribute self.Posizion.Y < 0:
Destroy this actor
I would like to Change attribute numFire of ACT1 (the father)

Can I change this attribute from SHOT actor ?

Or I have to do each global attribute for each ACT ? (ACT1, ACT2,..., ACTn)

Thanks

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Wow I have no idea what that is. Are you using a self attribute in the actor? For other actors to read it it must be a game level attribute.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

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

  • xitpuxitpu Member Posts: 2
    Thanks,
    you say:
    "In your actor that shoots bullets, add the condition When attribute game.bulletCount < game.maxBullets to whatever rule condition you already have.

    In your bullet actor, add a Change Attribute behavior at the top of its rules and change game.bulletCount to game.bulletCount + 1. When you destroy a bullet (in that actor or another actor, such as when a collision happens), change game.bulletCount to game.bulletCount - 1. You may also need to create a rule for when the bullet is off-screen (either based on self.Time or self.positionX/Y) and subtract one from the bullet count there are well."

    I can understand if I use this technique for the main actor, but if I have 10 or 20 different
    actors at time I need to have 10 or 20 different game attribute to check max bullet count for each ones ?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I can understand if I use this technique for the main actor, but if I have 10 or 20 different
    actors at time I need to have 10 or 20 different game attribute to check max bullet count for each ones ?
    Good question. Yes, but in that case I would recommend you use tables. You're new to GameSalad but what I'm going to suggest is quite complex. You may want to come back to it later after you've built a simpler game first to learn GameSalad well. My health bar demo "syncs" the positions and other attributes of two actors (in this case an enemy and a health bar but it would be the same for a gun and a bullet): http://forums.gamesalad.com/discussion/comment/384027/#Comment_384027.

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

  • xitpuxitpu Member Posts: 2
    Thanks for help,
    I understand the direction to take
Sign In or Register to comment.