Context, I’m making a vr game, and I need the hands to replicate to the server.
I’m firing a RemoteEvent constantly, would this cause lag? and if it does, is there a way to queue the event?
Context, I’m making a vr game, and I need the hands to replicate to the server.
I’m firing a RemoteEvent constantly, would this cause lag? and if it does, is there a way to queue the event?
Firing a remote event constantly might cause it to exhaust.
Yeah, but is there a way to ensure that the position will be tracked. But also not cause lag?
You could update the hands every frame client-sided, and maybe call a remote event to replicate it every .3 seconds or around there so it isn’t quite as stressful on the server.
Not sure if that’s already what you’re doing though, in terms of time waited per call.
Think of it like skeds vr playground (if you have ever played in vr). The blue boxes are where your hands are in the server. They don’t instantly teleport, they ease in to the position. I wan’t something like that.
Hm, I see.
Well in that case, maybe each time you call to the server to update the hands for other players to see, you can call :FireAllClients
and from there you can use TweenService
on each client to smoothly animate the hands to the position passed in from the server fired event, if that makes sense.
I could see that working very well. Hope this helps, can clarify if necessary.
The hands are unanchored, so TweenService wouldn’t work. I’m using AlignPositon, along with AlignOrientation. And I’m trying to tweak the settings right now.
I’ve never tried this, but maybe you could take that same idea except for the tweening, tween the properties on those constraints.
If you want a good way of updating information, do something like this:
Have server in a pcall constantly trying to invoke a remote function for a specific player
In that pcall you can get the player’s ping by checking how long it took them to respond.
The client could give the server information in the meantime too.
Server ping module
local assignFunc = function(player)
local rnd = math.random()
local t = time()
--check and handle other kinds of inputs
if pingRemote:InvokeClient(player, rnd, networkData[player]) == rnd then
networkData[player] = time() - t
end
end
local handler = function(player)
networkData[player] = 0
while player.Parent do
if not pcall(assignFunc, player) then
wait()
end
end
networkData[player] = nil
end
local Init = function()
pingRemote.OnServerInvoke = function(client)
Toolkit.Threaded(handler, client) --coroutine.wrap
return "OK"
end
end
Client ping module
local handler = function(rnd, myping)
module.Ping = myping
--you can give things to the server here
return rnd
end
module.Init = function()
pingRemote.OnClientInvoke = handler
pingRemote:InvokeServer()
end
Usually, I would make a function in the module where I can add things to do with extra data on both client and server
Checking ping is crucial to me making physics replicate smoothly so this is very useful.