Hi there!
Still working on my first project: an endless runner 2D game. At the moment I have a system where whenever a random chunk is generated, it also has a level generator which, based on the distance of the player, can generate the next random chunk on the endpoint of the current chunk.
Problem is that these chunks sometimes overlap, I want to avoid this. Does anyone have any ideas what the best way of doing this is?
I was thinking about using a box collidor and OnTriggerEnter to destroy the chunk when there is an overlap and generate a new random chunk (which would do the same overlap check, until a random chunk is generated that does not overlap). However I don’t think the OnTriggerEnter works with static objects generated within the box collider, or at least it’s not doing anything for me at the moment.
I was also looking at maybe something like Physcis.Overlap, but no idea how I should make use of that.
Maybe there are easiers ways of doing this, like doing a check before generating a new chunk.