So currently in my 2D game I have a bounce mechanic that occurs when the player or enemy decides to turn on their shield and it has contact with the ground, however it should not bounce when they are not enabling the shield.
To do this I’ve used an AreaEffector2D to simulate bouncing by launching them upward. This works perfectly when we just have one player or a preset number of enemies and keeps the x velocity throughout the bounce keeping them on path with the way they came into the bounce. However, I would like this to be multiplayer and have enemies spawned on screen.
This would mean I would need a specific layer and AreaEffector2D for every single enemy and player within the game since I only want that one gameObject to bounce, all made before run time. I have also found that the AddForce function seems to be inconsistent in making them bounce the same height every time which is why I have opted for the AreaEffector2D.
Now I was wondering if there are any alternatives to make only one gameObject bounce and not all enemies or players when the AreaEffector2D is enabled as they would be on the same layer. I could of course make an object pool and layer them all individually but this just seems very inefficient to me and would require multiple AreaEffector2Ds on top of each other with all different thrust amounts for all objects that bounce.
Am I going about this completely wrong or am I going to have to go the long route and create an object pool with an incredibly long layer list?