Heyo I’m currently working on a fighting game which is in a similar style to Super Smash Bros and I’m currently trying to add knockback I’ve found the formula used in Super Smash Bros and I’ve been trying to use and understand it, but I’m a bit stuck and could use some help getting it to work. I’m using these resources to help me out Knockback - SmashWiki, the Super Smash Bros. wiki (ssbwiki.com) and Smash Ultimate Calculator (rubendal.github.io)
Basically this is the formula used to calculate knockback (I’m pretty sure atleast)
p is the percentage of the target, counted after the attack’s damage is added.
In Melee , p is floored pre-hit percentage + stale attack’s damage.
d is the damage the attack dealt.
In SSB and Melee , it is the full damage without counting stale-move negation, except for [projectiles, which use the stale damage.
In Brawl , it is the damage including the staleness or the freshness bonus.
In Smash 4 and Ultimate , it is the damage including 0.3x of the staleness or freshness bonus.
w is the weight of the target. It is set to 100 if the attack is weight independent. Note that in SSB , heavier characters have a lower weight value than lighter ones, in accordance with the formula.
s is the attack’s knockback scaling (also known as knockback growth) divided by 100 (so a scaling of 110 is input as 1.1).
b is the attack’s base knockback.
r is a series of ratios based on a number of factors
Here is how I’ve tried to use this
local MoveData = {
Damage = 23,
KBG = 98, --knockback growth
BKB = 25, --base knockback
Angle = 361,
}
local Damage = MoveData.Damage
Target.Percent.Value += Damage
local Percent = Target.Percent
local Weight = 100 --would be weight of the target
local KBG = MoveData.KBG
local Scaling = KBG/100
local BKB = MoveData.BKB
local Ratio = 2.0
local KnockbackCalculation = (((((Percent.Value/10 + Percent.Value*Damage/20) * 200/Weight+100 + 1.4) + 18) + Scaling) + BKB) * Ratio
local LaunchSpeed = KnockbackCalculation*0.03
local Knockback = Instance.new("BodyVelocity")
game.Debris:AddItem(Knockback,0.3)
Knockback.Parent = Target.HumanoidRootPart
Knockback.Name = "Knockback"
Knockback.MaxForce = Vector3.new(1,1,1)*5000000
Knockback.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector*LaunchSpeed + Vector3.new(0,LaunchSpeed,0)
end
Result. Despite the dummy having a high percent the knockback is basically nothing.
As you can see in the formula (I cant see cus I am in dark mode lol) there are a number of constants. Try tweaking these as many different game engines use different measurement systems and it could be that the measurement system was originally in metres.
Just tried this but it doesn’t really affect it at all.
Honestly I probably don’t need to all of this and should probably simplify it, but I’m not good at math so I’m not sure how, but all I need or atleast all I think I need is 2 values one for how high it goes and how far it goes, but I’m having a hard time figuring out how I could make those values. Would you happen to know a solution? lol
Have you tried taking your entire calculation for the Knockback Velocity and multiplying it by a flat value, like say 10? Your Knockback looks very similar to Smash, but it needs more force to fit the Roblox engine.
The knockback is exactly from smash lol. Anyways no I’ve not tried doing that I’m not sure what you mean though are you saying to multiply this by 10? (((((Percent/10 + Percent*Damage/20) * 200/Weight+100 + 1.4) + 18) + Scaling) + BKB) * Ratio if so I don’t know how that would help because I already get a big number from this like 415 which will send the dummy flying if I try to use it or are you talking about this BV.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector*HorizontalValue+ Vector3.new(0,VerticalValue,0)
I added prints and heres what everything equals:
Knockback = 517.36
LaunchSPeed = 15.5208
BV Velocity = -0.6626876, 155.207993, -15.5066462
Edit: do you know any other way I could get values for this? BV.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector*HorizontalValue * 10 + Vector3.new(0,VeritcalValue,0)
How about changing the max force higher;
if that does not work try to find the weight of the target
Knockback.MaxForce = Vector3.new(1,1,1)*math.huge
function GetModelMass(Model)
local Mass = 0
for i,v in ipairs(Model:GetDescendants() do
if v:IsA("BasePart") then
Mass += v:GetMass()
end
end
return Mass
end
Yeah… maybe 10 is a bit too high. You can probably lower it to around 2 ~ 3 to get a knockback effect with a similar magnitude to Smash. Also that value looks about as good as you can possibly get it.
Yeah lowered it down a bit and it seems to work a bit better now however it’s defiantly still a bit wack although it works so I guess I just gotta improve it overtime here’s how it currently works.