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