detect collided spawned instance

hello, i am trying to detect instance that his something in the scene so i can hide it and increase score later, this instances are spawning while the game play, i tried to create a game attribute, and to increment it every time i spawn an instance, then to assign the value of this attribute to the spawned instance local attribute, and when i collide with it i (somehow) get this attribute ..
i tried a lot but with no luck, could someone please tell me the ideal way to do this , thanks !

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Are you trying to keep track of which instance is colliding? Or just trying to keep a count of how many instances collide? Or just trying to destroy the instance when it collides?

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

  • artwaveartwave Member Posts: 23
    i need to access attributes of the collided instance, here is an example:
    1-actorX has multiple instances spawn automatically in random places, each one has an internal attribute holding an integer
    2-when player collide with a specific instance, i need to add this integer inside the instance to my score
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited April 2013
    So if I understand it correctly, each of the spawned instances (of a single actor) is worth different point values towards the score? How do you plan to assign those values?

    If you are able to use a different actor for each type of actor that spawns, then you don't need to worry about instance attributes at all. You just do:

    When actor collides with [player actor]
    .....Change attribute game.score to game.score+self.value

    The hardest part is assigning the values, but you could do that from a table by increasing the row number before each spawn. I'm not going to write out all of those rules but if you just want to increase the value by one (as an example), this will work:

    Spawner actor
    Change attribute game.spawnCount to game.spawnCount+1
    (if using a table, Change Attribute game.tableRow to to game.tableRow+1)
    Spawn actor [actor name]

    Spawned actor
    Change attribute self.value to game.spawnCount
    (if using a table, Change Attribute self.value to tableCellValue(tableName,game.tableRow,1))
    When actor collides with [player actor]
    .....Change attribute game.score to game.score+self.value

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

  • artwaveartwave Member Posts: 23
    thanks tatiang , that works !
Sign In or Register to comment.