Running large AI vs AI fights with lots of projectiles without lag

Okay, so I made AI ships for my space ship fighting game that can fight both players and other AI. I quickly found out that spawning a lot (which i was planning to do with some events) would cause extremely high projectile lag. To fix this, I made it to where the server sends info about the projectile (velocity, CFrame, etc.) to all of the clients and have the clients create their own projectiles, while the server deletes the original one. This worked perfectly in getting rid of the lag.

Then came a new problem: How would I detect hits? AI vs Player or Player vs Player would be fine, since the hit detection could be handled on the client’s side. However, AI vs AI has no client involved, and… as I stated before, the projectile was deleted on the server to get rid of the lag. Does anyone have some ideas I could try out? Thanks

2 Likes

One thing you could try is keeping a super lightweight version of the projectile on the server, just for hit detection between AIs. Don’t render or simulate it fully, just update its position based on the velocity you already have. If you want, you could render rest of the projectiles in the client.

1 Like

so i could maybe anchor the projectile, make it invisible, and then just update its position value every tick?

1 Like

Yeah, or you could just use a raycast instead. Try both and see which one works better for your setup.

alright, I’ll let you know how it goes

1 Like