I know, it’s ridiculous: "Server-side version of a client-side property? WHAT?! "
Unfortunately with the lack of a server-replicated property - even a mere Vector3 - of a client’s mouse location in 3D space, I have to resort to the worst possible method of getting that information:
local MousePos = Vector3.new()
while wait(0.1) do -- https://www.youtube.com/watch?v=WtJsHWdUHwE !!!
MousePos = SomeRemoteFunctionToGetMouseHitP:InvokeClient(Client)
end
Note: I use a RemoteEvent fired from the client in my own code, should you continue reading the thread.
So, how could a server-version of the client’s mouse position possibly be beneficial?
No more network intensive code (like above code-snip)
An easy way to run things like guns/turrets (that have a client controlling them) from the server
The need for FE-Compliant (laggy, like above code-snip) code is gone for things like this.
I’m sure there’s more ideas that people could add.
The main reason I need it is because, similarly to one of my examples, I’m trying to make a car with mounted guns that a player can drive. With FE, I can’t use a LocalScript to drive the car and turn the guns - I have to do it on the server so that it replicates. This means that, as I said in my original post, I have to resort to repeatedly calling a RemoteFunction / RemoteEvent for the server to know where my client’s mouse is.
This is not a very good idea in terms of user responsiveness though
You might want to visualise someone else’s pointer (i.e. in a drawing game, or something like table top simulator).
IMO does not need to be an engine feature though, especially because it can be solved with a little bit of Lua code. Networking would happen anyway, it would just be by the engine then instead of your code.
If you can make the argument for the mouse position replicating, you can make that argument for a lot of properties (and people most-likely will if this happens).
You don’t need to request it from the client every time you need it. Just have the client constantly send the mouse position to the server and cache it.
You should store the direction relative to the car.
If the car turns left, the gun also turns left, but relative to the car, doesn’t move.
You only need to (re)send the direction if it changed (too much).
A mouse hit location is not the same for every game because some games want to filter transparent parts, others want to filter something else when casting a ray from viewport to world.