What is the best way to make a knockback effect without using look vectors?

The title says it, no Look Vectors. I’m trying to get the direction right.

3 Likes

Look vectors is literally your best friend here.

local targetPos = --the position of the thign thats being knocked
local sourcePos = -- source position of impact

local lookVector = CFrame.lookAt(sourcePos, targetPos).LookVector

local magnitude = 5 -- how powerful you want the knockback to be
humanoid.Parent.Torso.AssemblyAngularVelocity = lookVector * magnitude

Otherwise you would have to manually calculate the direction of the knockback, which sucks.

1 Like

Ok, I’ll try that out. Will it have the right direction? Like if the target is moving away from me, I don’t want the knockback force to go to the wrong direction.

It should calculate at the instance you want it to, you may have to change the magnitude to see the effect

AngularVelocity? Don’t you want to use LinearVelocity?

Oh yea sorry, I forget they had two different properties for that.

Is it better to use assemblyvelocity or applyimpulse() ?

Didn’t even know ApplyImpulse was a thing, but it sounds like it’d work.

WAIT! Make the hit player face the hitter before knocking them back with the lookvector.

What will happen if the source is at the top of the target, what will happen to the knockback force direction?

Setting AssemblyLinearVelocity directly might lead to unrealistic motion so its preffered to use ApplyImpulse.

But this can only be used if the ownership is on the server right

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