Scripting a projectile

Reading around this forum it seems everyone has a different opinion on how to create projectiles (BodyMovers, Raycasting, CFrame, VectorForce) and how to network them. I’m new to projectiles and have two questions:

Which of these four is the least performance cost?
Is there a correct way to network a projectile?

Thank you

1 Like

TL;DR: I would use raycasting, and networking a projectile always has its downsides, but networking to the client is the better option.

  1. Raycasting and CFraming are basically the same thing, with the key difference being extra overhead vs inaccurate hitboxes.
  2. VectorForces are undeprecated, but screw that because BodyMovers are easier to use.

In my opinion, I would use Raycasting/CFrames because it is so much more accurate than letting the physics engine take control. Destroying the bullet feels like it would be a pain.
Between those two, raycasting is even more accurate than CFraming because there is no chance for collision to skip a beat and pass through a player, and technically bullet hitboxes hit on the surface of whatever the bullet was targeted at rather than their current position during that frame.

As for networking a projectile, I have heard that most mainstream FPS’s leave hitbox detection to the client. However, there are some serious consequences from exploiters taking advantage of this. This comes from two things:

  1. Your bullets are predictable and can be aimbotted, which can be fixed by adding bullet drop, and
  2. Exploiters can simply remove your local gun scripts and inject their own, probably in an unidentifiable way.

However, networking over to the server is a much worse decision because then you make the gameplay lackluster because bullets will shoot out your gun based on your ping rather than your reaction time.

Also, I have never once coded an FPS, so you might want more rehearsed opinions than just this.


Alright, thanks for the reply.