spawn same actor with different attribute

IceboxIcebox Member Posts: 1,485

Hello is there a way to do this :

I have 3 enemy actors on scene ( all the same actor just dublicates)

Enemy1 = if touch is pressed > spawn actor1 that have self.integer 1.
Enemy2 = if touch is pressed > spawn actor1 that have self.integer2.
Enemy3 = if touch is pressed > spawn actor1 that have self.integer3.

I can do it by spawning different actors but ill need so many so i got stuck, is this possible ?

thanks

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2016

    You can "pass" an attribute value from one actor to another using this method:

    Give the enemy actor a self integer attribute. In each instance on the scene, manually assign the value of that attribute. Or, if you prefer, you can assign it any other way you like (e.g. by retrieving an attribute or table cell value).

    In the enemy actor, change attribute game.spawnerID to self.ID. Then spawn actor 1.

    In actor 1, change attribute self.ID to game.spawnerID. This should not be inside of a rule.

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

  • IceboxIcebox Member Posts: 1,485

    @tatiang oh ,something so simple yet i was thinking about tables and over complicating things , appreciate the quick response and thank you .

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You're welcome!

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

Sign In or Register to comment.