So the first way I thought of was to just create a projectile, create a body velocity, and launch it in the direction of the client mouse. This would be on a server script event and the client mouse location would be an argument to the OnServerEvent
call. It is tempting to just create a RemoteFunction
and InvokeClient
to find the current mouse location but invoking the client from a RemoteFunction
is insecure and should never be used.
The projectile is fired after a delay upon being activated. Currently I am working on a spell that needs to form in the users hand for some time before firing. This means I cannot just send the mouse location in the original activated event, the players mouse location can change while they are forming the spell and that will not be accounted for.
Besides that, the projectile is fired, and if I just add a body velocity on the sever, when the projectile goes far enough away the network ownership will change to the server causing a short pause in the projectiles motion. If I set the network ownership to the client, then the client is trusted to make the projectile go where it should and handle touch events. This could be a problem with expoiters or if the player leaves the game after the projectile is fired but did not hit and explode yet. Alternatively I can set the network ownership to the server, so the server handles touch events. However this still creates a hop as the network ownership changes, just when the projectile is fired instead of at some arbitrary distance from the user. What is the best way to create a projectile with smooth behavior?