Is it better to set the ownership to the server, or to the client who fired it? Setting it to the server will result in a lag right when the projectile is fired
Setting it to the client is ‘trusting’ the client not to be exploiting, and also relies on the client to listen for touched events, so if the client leaves after firing a projectile, the projectile would become inert and fall out of the sky if the client was responsible for the body velocity making the projectile move.
Not really no, the projectile itself should just be for visual feedback. The raycast should be handled on the server. You should be safe handling the visual projectile’s network ownership on the client. I wouldn’t recommend using a touched event for damage logic though.
There should be multiple tutorials on Raycasting in both the forums and YouTube, you could also check out modules people have made such as FastCast.
Also touched has a slight delay and isn’t as reliable in general compared to raycast and magnitude so if you’re trying to make skills or bullets you’d want to use those over a touched event.
Touched event is slower and less accurate than ray casting. A ray is a line that can go for thousands of studs and can accurately get everything that it comes in contact with. A projectile should just only used for visual and not actual game play as if the client had access then a exploiter can move the projectile.
So considering the speed of the projectile, at the time firing would said person have been hit by the bullet? If so, then you should apply damage to them. Otherwise, they didn’t get hit by the projectile.
Usually you’ll do this verification on the server.
I actually use .Touched for all of my projectiles and despite people saying I shouldn’t I have yet to experience any issues even when the server is laggy the projectile only travels slower but the hits always register.
But if your projectile is instant you should definitely use raycasting. Otherwise .Touched shouldn’t be a problem. This is only from my personal experience though. If you think another way of detecting hits would be better than go for it.
Honestly, that I’m not sure. I don’t specialize in FPS mechanics. Though I have looked into it and I play around with code regarding shooter mechanics from time to time.
@yoolurs it’s not like you can’t get away with using .Touched, but it just depends on the type of gameplay you’re looking for. .Touched will never be as accurate as a raycast and depending on the type of game it can lead to a frustrating experience for players.
If there’s perhaps some developers that do have more insight into FPS / Shooter mechanics perhaps they can provide you with some more information.
Oh. Yeah then don’t use .Touched
I use it with projectiles that travel at a decent speed like throwing knives and such. I wouldn’t advise using it for things like bullets where they travel extremely fast and the projectile itself is small.
You could make it so the second someone shoots a position where the bullet is headed will be determined. The bullet will then constantly raycast from its position in the direction its traveling in by a few studs. If the raycast detects a player then damage them.