Jump to content

Recommended Posts

I am working on a server mod that can issue WalkTo commands to players. It works fine without predictive mode, but with it, the player slides and is uninterruptible. This is my logic:

GLOBAL.STRINGS.ACTIONS.ACTIVATE.FOLLOW = "Follow"

local function OnActivate(inst, doer)
    local pos = inst:GetPosition()
    local delta = GLOBAL.Vector3(20, 0, 0)
    doer:DoTaskInTime(1, function()
        local action = GLOBAL.BufferedAction(doer, nil, GLOBAL.ACTIONS.WALKTO, nil, pos + delta, nil)
        doer.components.locomotor:PushAction(action, true)
    end)
end

AddPrefabPostInit("arrowsign_post", function(inst)
    inst:AddComponent("activatable")
    inst.components.activatable.OnActivate = OnActivate
	inst.components.activatable.quickaction = true
    inst.components.activatable.forcerightclickaction = true
	inst.components.activatable.inactive = true
    inst.GetActivateVerb = function(_inst) return "FOLLOW" end
end)

How do I avoid this issue?

Solved this!

I took a different approach. Instead of controlling players strictly on the server side, I relayed to the client, and had the client perform the action. In a client component, I use this logic:

if self.inst.components.locomotor then	--lag compensation ON
  local action = BufferedAction(self.inst, nil, ACTIONS.WALKTO, nil, pos)
  self.inst.components.locomotor:PushAction(action, true)
else	--lag compensation OFF
  SendRPCToServer(RPC.LeftClick, ACTIONS.WALKTO.code, pos.x, pos.z)
end

This will work for both predictive mode on and off.

Edited by cybers2001

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...