Server-side projectile hit detection without Touched event

so basically i want the server to handle all the actual game logic (hit detection, damage calculation, etc) while clients just render the fireball visual, I dont want to spawn any parts on the server at all just pure calculations.

issue:
the main issue i keep running into is that most tutorials just use Touched events on a part, but from what i’ve read those are pretty unreliable especially with fast projectiles. plus if im spawning parts on the server it feels kinda inefficient?

WorldRoot:Raycast, WorldRoot:Blockcast, WorldRoot:Spherecast, WorldRoot:Shapecast depending on what you want. For small projectiles Raycast is fine. For bigger ones you can use one of the other methods. If you want gravity or travel time you’ll need to split the path into multiple casts. This is pretty much what modules like FastCast already do for you.
Also Actors probably.

1 Like

Correct, this is why people make fun of tutorials aswell. Touched is fine for simple detections like on a killbrick but definitely not recommended for gun systems or combat systems where hit detection needs to be much more reliable and accurate.

This is when you should use spatial query methods such as raycasting or getpartsboundsinbox.

2 Likes

If your projectiles need physics, I’d prefer to simulate the physics on the server and visualize them on the client, but synchronization would unfortunately be lost. To allow the server to simulate projectile physics without replicating it to clients, you need to move the projectile into workspace.CurrentCamera.

For hit registration, I would use GetPartsBoundsInBox in HeartBeat. Between the last position and the newly simulated one, call GetPartsBoundsInBox, calculating the distance between them

1 Like

hum, should i put the object into current camera??

Yes, it sounds weird, but it actually works. If you place a Part in workspace.CurrentCamera, it disappears on all clients, and any property changes on the server won’t be replicated. I don’t know why that happens, but it’s awesome.

For example, take a column of 10,000 parts moving forward and knocking down physical parts on the server. If I moved those parts on the server, recv would spike to 1000 KB/s. Here, the client visualizes the parts, and the server handles the physics simulation

1 Like

omg, this feature will be usefull, thanks so much

Are you saying you can use this for lots of projectiles server side?

Do you have an example .rbxl of where the server does the projectile and does damage?

Thanks

Could you explain how you’re visualising on the client? You’d have to send the info to the clients so it’s still technically replication. But obviously maybe less frequently replicated, well I don’t really know for sure what ur doing..

I’d suggest actually simulating physics on the client. The server already has alot of work to do, simulating the physics is just putting an extra burden on it when u can easily save the server some stress here.

And I’d recommend parenting parts u don’t want to replicate to clients to server storage just for good practice. I mean everyone knows server storage items don’t replicate to clients so.

I implemented this system, and it works well with static NPC. However, for NPCs that move randomly every second, hit registration becomes inaccurate

Why does hit registration become bad? If you lerp on the server separately and lerp on client separately. They should both be moving at a negligible difference since the server has no replication involved it’s basically just as fast as the client.