Here is the issue.
- I have multiple, instances of a certain subset of objects moving around within my gameworld
- They collide, spawn a new object … and then continue on their way
The problem is with the continue on their way bit. This results in a whole sequence of other collisions occuring between the same two objects and I do not want that to trigger any further spawning of new objects.
I should explain that at any given time I may have as many as 16 instances of the object. Call them O1…O16. So imagine this
- O3 collides with O14
- A new object of the same type is spawned - there are other events happening in the world that will suppress some of these objects so object growth is never going to be unbounded.
- Since O3 and O14 still exist and continue on their current trajectories there will be more collisions
- I want these subsequent collisions to be ignored for a while
The work around I have found for now is this
- I define an object property *go.property(“last_collided”,0)
- In the init method I self.last_collided = 0
- In the message handler I check *(os.time(os.date("!*t")) - self.last_collided )> 1 * (ignore for 1s) prior to responding to the collision. As a side effect self.last_collided is updated.
This works. However, I am new to game development so there may well be a neater way to avoid this in Defold that I am not aware of?