Detecting current physics objects before placing new ones

I am making a game where you jump from platform to platform, and the platforms can be different heights. I generate objects randomly as the player goes, but sometimes they generate within the platforms. I could set them above the tallest platforms but then the player couldn’t reach them if they are on the low/mid level platforms.

I generate the platforms before I generate the objects. Does anyone know of a good way to detect existing physics objects before placing new ones? I want to be able to place the new objects within an attainable height above whatever platform is there.

Thanks!

-Treb [import]uid: 181948 topic_id: 33799 reply_id: 333799[/import]

Hi Treb,
One idea is to store your platforms in a holding table when you create them. Then, loop through them and figure out their Y position and width (one by one, working through the loop). Using that, you could say “place a collectible object 100 pixels above this platform (or not) and then within a random range of its left and right edge”.

Brent [import]uid: 200026 topic_id: 33799 reply_id: 134351[/import]

Thanks Brent!

Can’t believe I didn’t think about that! I already store the platforms in a list so that shouldn’t be too hard to do.

-Treb [import]uid: 181948 topic_id: 33799 reply_id: 134368[/import]

Hi Treb,
One idea is to store your platforms in a holding table when you create them. Then, loop through them and figure out their Y position and width (one by one, working through the loop). Using that, you could say “place a collectible object 100 pixels above this platform (or not) and then within a random range of its left and right edge”.

Brent [import]uid: 200026 topic_id: 33799 reply_id: 134351[/import]

Thanks Brent!

Can’t believe I didn’t think about that! I already store the platforms in a list so that shouldn’t be too hard to do.

-Treb [import]uid: 181948 topic_id: 33799 reply_id: 134368[/import]