Battleground Knockback Improvement

Hello Again.
This is my second topic about knockback in my battleground game. Below is a comparison video showing the knockback effect I want versus my current implementation.
video thats shows what i want to have and mine

What I’ve Done So Far:

  • Implemented knockback using BodyVelocity and VectorForce.
  • Added animation transitions, but they still feel slightly delayed.
  • Adjusted force application timing, but it’s not as smooth as I’d like.

the recap, i wanna get rid off the laggy feel.

Scripts…

Hitservice :

function module.activate(enemyhum, damage, stundaur, knockback, attackerknockback, attacker, ragdoll, ragdolldaur, notplayinganim, force)
    local enemy = enemyhum.Parent
    local enemyhumRp = enemy:WaitForChild("HumanoidRootPart")
    local attackerhumRp = attacker:WaitForChild("HumanoidRootPart")

    if damage then
        enemyhum:TakeDamage(damage)
    end

    local animator = enemyhum:FindFirstChildOfClass("Animator")
    if not animator then
        warn("Animator not found in humanoid!")
        return
    end

    if not ragdoll and notplayinganim ~= true then
        local randomAnim = math.random(0, 1)
        local damageanim0 = animator:LoadAnimation(hits.Hit1)
        local damageanim1 = animator:LoadAnimation(hits.Hit2)

        stopanims(animator)
        if randomAnim == 1 then
            damageanim0:Play()
        else
            damageanim1:Play()
        end
    end

    if typeof(knockback) == "Vector3" then
        local bv = Instance.new("BodyVelocity")
        bv.MaxForce = force or Vector3.new(math.huge, 0, math.huge)
        bv.P = 50000
        bv.Velocity = knockback
        bv.Parent = enemyhumRp
        debris:AddItem(bv, 0.2)
    end

    if typeof(attackerknockback) == "Vector3" then
        local bv = Instance.new("BodyVelocity")
        bv.MaxForce = Vector3.new(math.huge, 0, math.huge)
        bv.P = 50000
        bv.Velocity = attackerknockback
        bv.Parent = attackerhumRp
        debris:AddItem(bv, 0.2)
    end
end

last thing variable of knockback power is 12 for normal and last m1 is 40

I did something similar before, except I used :ApplyImpulse() which worked amazingly, you should give it a try too!

you can use this code example

local knockbackdirection= directionhere -- LookVector
local knockback = 0.9 -- set to a low number first since it may be very sensitive
local gravity = workspace.Gravity -- might need to lower this value to make it fit your needs

local rootpart = humanoidrootparthere
rootpart:ApplyImpulse(
((knockbackdirection*Vector3.new(1,0.1,1))*knockback)*rootpart.AssemblyMass*gravity
)

Side Note, MAKE SURE to apply the knockback on the hit player’s client, using FireClient() or whatever… as long as the ApplyImpulse is done on the client

1 Like

the knockback i am using is on the server. ill try it and tell you.

1 Like

i think he was talking about the apply impulse being on the hit client, but server handled knockback could be attributed to the lag, especially when u have many players hitting

1 Like

hmm, i pulled up an old project of mine which i think just fires to all clients to apply the knockback but im getting that same laggy feel. im not too sure how this can be fixed. the only thing that comes to mind is character replication. i found this post a while ago Stupid simple fast character position replication - Resources / Community Resources - Developer Forum | Roblox. this would not only hepl with knockback but just latency in general. you can try this if u want, although i havent tested it myself

1 Like

ill try solutions and tell yall thanks for help @Herstal_PinkP90

1 Like

np, hopefully one of these suggestions work

1 Like

BetterReplication | Vastly improve your combat experience by fighting LAG! i found this too ill see it.

@Herstal_PinkP90 @ABizarre_Dummy
i putted 2 replications the one u send and mine its working good! still 1 problem the knockback power and anim playing feel meh. ill try to fix it anyways tysm guys !

np! but i would appreciate if you could mark either @Herstal_PinkP90’s post or my post as the solution if it did lead to the solution. if not, thats alright. good luck with future development!

1 Like

i put mine as you 2 give me the solution.

1 Like