I’m working on a battleground-style game and I’m trying to decide the best way to handle knockback. I’ve seen different approaches like using BodyVelocity, LinearVelocity, or directly setting the character’s velocity/assembly linear velocity. I want the knockback to feel smooth, responsive, and consistent across clients without causing physics issues. What’s the best way for knockback in this and why?
just a little bump
type or paste code here
Apparently this is good (from here)
local Speed = 40
local Force = 80000
local Character = --character you want to knockback
local TotalForce = Force
local KnockBack = Instance.new("BodyVelocity")
KnockBack.Parent = part.Parent:FindFirstChild("HumanoidRootPart")--part is the target of the knockback/ the opponent
KnockBack.MaxForce = Vector3.new(TotalForce,TotalForce,TotalForce)
KnockBack.Velocity = Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * Speed -- based on the direction YOUR character is facing.
BodyVelocity’s are deprecated, it’d be best to use :ApplyImpulse() on the HumanoidRootPart, more info can be found here