How to get rid of BodyVelocity delay on all clients?

I’ve been working on a combat system heavily inspired by Smash Bros. with aspects such as knockback scaling and velocity.
One issue I faced when testing with other people or on my own in studio is that the BodyVelocities on the players were different on each others screens. On the screen of the player getting hit, it’s perfectly fine and works smoothly, but on every other player’s screen it’s delayed.

The BodyVelocity is created in a LocalScript which is in the character getting hit, through a RemoteEvent. The reason I chose to do this is because I have no idea how to make it smoother than that. Originally I had it in a ServerScript that was handling the attacks from the attacker. I thought switching to a LocalScript would somehow help but there was no difference.

I’ve tried using other methods to control character velocity, (ApplyImpulse, LinearVelocity, AssemblyLinearVelocity) but the results either stayed the same or did not work as I wanted. BodyVelocity is still the most reliable method for me.

Also, it’s very important for me to note that I’ve seen other devs use the EXACT same simple method; instancing the BodyVelocity, adding it to the HRP, setting its velocity and maxforce, then adding it to the Debris service, even some games instancing it on the server and not the client, with it working much more smoothly/without much delay. What am I doing wrong?

Video:
https://streamable.com/zd0zuw

This is what the localscript velocity handler on the receiving end looks like:

local remote = game.ReplicatedStorage.RemoteEvent
local char = script.Parent
local Debris = game:GetService("Debris")

remote.OnClientEvent:Connect(function(vel, duration, tweenData)
	
-- create and destroy the bodyvelocity
	local bv = Instance.new("BodyVelocity")
	bv.Name = "Knockback"
	bv.MaxForce = Vector3.new(50000,50000,50000)
	bv.Velocity = vel
	bv.Parent = char.HumanoidRootPart
	Debris:AddItem(bv, duration)
	
-- tween the velocity for specific type of moves (ignore this unless applicable to question)
	if tweenData then
		game.TweenService:Create(bv,TweenInfo.new(tweenData.tweenDuration),{Velocity=tweenData.tweenVelocity}):Play()
	end
	
end)
2 Likes

A great start would be to not use BodyVelocity as it’s deprecated. Use LinearVelocity instead.

I already noted that I tried using LinearVelocity. It gave me the same results. Even if I use it I don’t know how to get rid of the delay.

Ah ok, I still suggest using LinearVelocity over BodyVelocity as it maintains a relative or absolute linear velocity along one or more axes and occording to google, LinearVelocity is a more powerful replacement for BodyVelocity.

On the other hand, this thread may help out:

Try using :ApplyImpulse() as an alternative method.

My 2nd idea is that its due to humanoid force resisting causing the delay. Try setting the humanoid to platform stand for a few seconds in task.spawn then disabling it.

Below is just testing with an onserver method, just for extra knowledge doesn’t appear to be the best solution either.

1 Like

From my testing, ApplyImpulse is still quite laggy. I tested the StateType method just now but there still really isn’t much of a difference. I’m sure that connection issues could also contribute to this but I really don’t think these are too much better in my case.

I’ll continue trying to combine these ideas to see if I can resolve this. If there are any better methods please let me know.