GPF104 / GPF104_Game

0 stars 0 forks source link

Portal Spawn Logic #146

Closed Gard-en closed 1 year ago

Gard-en commented 1 year ago

As enemies are getting stuck on world props when spawning in, we need a way to remove world props when a portal spawns in.

My solution to this is to do a 2D raycast when a portal spawns in. It detects tiles and props within a certain radius and destroys them if they're found, reducing the risk of enemies getting stuck when spawning in.

This also tidies up the map considerably during the late-game stage when portals form a sort of maze around the central tower.

Gard-en commented 1 year ago

Set clear radius to use float serializedfield for ease of modification.

Gard-en commented 1 year ago

Doing it in a function was too expensive, moved to IEnumerator and unset tiles every frame instead of all at once.

Gard-en commented 1 year ago

Map cleanup causing some FPS spikes, going to try and optimize or slow the code execution down to reduce chug time.

Gard-en commented 1 year ago

The below shows the logic behind the initial spawner spawn logic. It doubled every 15 seconds, which is why after 2:30 minutes, the code had executed 8 times, resulting in 256 spawners all running their own code.

Image

Now it's just a random number of spawners between 1 and 5. Fixed.