detect collided spawned instance
artwave
Member Posts: 23
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 !
i tried a lot but with no luck, could someone please tell me the ideal way to do this , thanks !
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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
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