Should I use lerping as an alternative to BodyMovers for knockback?

I have created a knockback script that works fairly well, this issue is that it uses body movers which are extremely buggy and annoying to deal with. E.g. when an enemy is holding a weapon the knockback doesn’t push them as far back when compared to if they weren’t. I am looking to just lerping the player but I’m not entirely sure that’s the best alternative to BodyMovers so I wanted to first check if it’s a good alternative, and if not, if are there better alternatives. Thanks in advance.

You could try playing around with the new velocity methods, such as BasePart:ApplyImpulse(Vector3 force)

This would have to be executed locally, however. You could try firing a remote to the client who is getting attacked to apply an impulse on their character. Might be a bit more fluent than using body movers.

2 Likes

Sadly this is exploitable, as an exploiter could just do this

KnockBack.OnClientEvent:Connect(function()
    --return nil
    HRP:ApplyImpulse(Vector3.zero)
end)
1 Like

Physics-wise they already own their character, so they can technically exploit their physics already.

Your other option would be to force their character to move in a specific way, which would be tweening or lerping, but that probably would not be as seamless.

3 Likes

Not to mention, it wouldn’t take into account any other out-lying circumstances like other applied forces without custom implementation. I agree with @C_Sharper, ApplyImpulse is probably the best solution.

1 Like

Or you can use AssemblyLinearVelocity with the network ownership set to the attacker.

1 Like

Then you run into a completely other exploitable issue. I.e network ownership also defines whether calling break joints from the attacker’s perspective would replicate to the server and cause the character to die, among many other things. This was found with a common exploit on NPCs through the auto network ownership.

1 Like

You could also be able to set network ownership to the server.

From my test results this will make 2/3 parties agree which are the attacker and server. The sole exception is the victim which will see it as laggy.

Just a suggestion with a test place for preview.

I believe the 100% optimal best method would be to create a custom state system similar to Chickynoids with rollback netcode and as described on the github “smoke and mirrors to make this still feel good and not laggy for the player, which is sometimes called player prediction.”.

3 Likes

I put it inside a module script and executed it from a server script. Tested it on a dummy and it looks like it’s working fine with my only issue being that it looks slightly choppy. Is there another reason to execute from a local script that I am unaware of?

KB function in module script -

function combatModule:knockback(plrHrp, enemyHrp, plrKB)
	if plrHrp and enemyHrp then
		local kbDir = plrHrp.CFrame.LookVector*plrKB
		
		enemyHrp:ApplyImpulse(kbDir)
		print("kb applied")
	end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.