Alright when the projectile is hit its removed completely, and yes the server raycasts for hit detection with no model while the client raycasts with a model for visuals. When the bullet on the server is hit the server bullet gets desotryed. Same with the client bullet, when the client bullet is hit the client bullet gets destoryed.
The bullets also get destoryed when they move 400 studs server or client. Server would just be removing the bullet from the table ect cause it has no model.
The client Never Communicates to the server after the bullet is created. The server does hit detection in it’s own to prevent exploiters, before this I have had systems which made the client fire if the projectile was hit, not only was it hard to make it was also spamming the server with a lot of requests, causing latency issues. The server and the client and the nonshooter clients manage the bullets by themselves.
My bullets aren’t hitscan the server doesn’t do a ray one time for each bullet. Instead, it does a ray for each nextposition the bullet goes to until it is destroyed. this is because people can move during the projectile running so for hit detection I use multiple rays until the bullet gets destroyed.
Each time the bullet moves a raycast is made, wheater on the client or server, except the server one has no physcial representation. So thats a lot of ray because for each bullet the server might do 5 to 6 raycasts depending on the velocity and the distance the bullet gets destoryed.
Some things I also do is disconnecting the hearbeat loop when theres no projectiles running and run it when theres atleast 1 projectile (optimization). Basically what I do is make a bullet on the client tell server to make it, and then the server pings all the other clients which arent the shooter to make a bullet to which is used for visuals like the shooter one.
For ping compesasation I add the amount of elapsedtime from when the client created the bullet to when the server recieved the message. And raycast there to see if the bullet is already hit, if not then I just start it from the position it should be on that elapsedTime. Same for lag compesation on the other clients which didn’t fire the gun but need to display it except they get compesated from when the client shot the bullet to when they got the message
My bullets run on a equation something like this: Distance = ElapsedTime * 3dVelocityRepresntation that’s why there always are where theyre supposed to be regardless of the framerate being low.
Object pooling is a bad idea I tried it before and it wasn’t the best solution for me. If you really want to try it I reccomond reusing the object pool.
If you have any other questions you can ask me.
Incase you were wondering it took me about a half a month to think of this system, I experiemnted with many systems and this one seemed the best!
Im suspecting your using instant projectiles and not projectiles which take time as a consideration, so the server doesn’t cast a ray for EACH bullet every frame until it’s destoryed, which is about 30 raycasts per frames for each bullet if the bullet takes 400 distance to travel and speed of 400 without hitting anything. My projectiles do take time as a consideration so you will be able to handle even more then mine, since you will not have to cast 30 rays for each bullet if the bullet isn’t hit
If this is the case you can handle way more projectiles then mine using a basis of my system except of a raycast for the projectile every frame instead since it’s a instant projectile you can do 1 raycast per bullet
Nice I did a stress test and I can handle 400 bulets a second, at 40 to 45 fps on my good computer, don’t know about the other one tho.