i have been trying to create a clean and responsive combat system, utilising bodymovers to handle the knockback. the knockback is applied on both the attacker and the victim, as a push and pull force. when tested on NPCs, it works great, and is really smooth. the problem is on the players. more often than not, the enemy player will have a strange delay with their knockback, disrupting the flow.
> local d = (V1.PrimaryPart.Position - c.PrimaryPart.Position).unit
>
> local push = Instance.new("BodyVelocity")
> push.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
> push.Velocity = d * 20
> push.Parent = V1.PrimaryPart
>
> local pull = Instance.new("BodyVelocity")
> pull.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
> pull.Velocity = d * 20
> pull.Parent = c.PrimaryPart
>
> game.Debris:AddItem(push, timer)
> game.Debris:AddItem(pull, timer)
i have read countless forum posts, and while i did gather some knowledge, none of it is helping me squash out the unbearable lag. one method i tried was setting the networkowner of the enemy’s humanoidrootpart to the character, and it didnt change too much.
an alternative method i have tried is using bodyvelocity for only the player, and instead, using alignposition on the enemy. this was also extremely laggy, but when i set the networkowner of the humanoidrootpart to the attacker, it made the attackers POV a lot smoother. the one downside is that the enemy’s POV was still, extremely jittery.
so, basically, i have tried to use bodymovers to create a knockback system, and while it works on NPCs, it is unusable on players due to the delay/lag.
any ideas on what is happening/better methods for knockback/how to reduce the delay?
thanks.