Hi everyone! It’s been a while.
I have a question about asteroid generation.
Previously, I would generate the asteroids randomly throughout a certain area. For instance, maybe I generate 250 asteroids in a range of -10000 to 10000 x and y.
However, I realize that this is inefficient. There are too many physics bodies on screen and the player might not even wander into a certain area, making those asteroids obsolete and adding to lag. I have seen this in my game, as I knock into asteroids, they push into others and keep going off screen. These collision events are slowing my game down.
I have decided to generate based on the camera. So, basically, as the player is moving in a certain direction, asteroids will appear in front of the player, and disappear behind the player. However, I am not sure how I would generate the asteroids this way. I have the asteroid creation and collision code, just not the positioning.
Long story short, I don’t know how to place the asteroids in a certain coordinate that the player is facing at.
Any tips on that would be great!
Happy holidays!