Using Body Velocity Or Body Gyro for knockback

Hello, I’m making a game where I need body velocity or body gyro knockback, which one should I use? Or should I use both?

1 Like

body velocity and bodygyro are both deprecated, linear velocity replaces body velocity and align orientation replaces body gyro.

1 Like

Thanks for the information I’ll make sure to use those, but I’m making knockback should I use Linear Velocity or Align Orientation or just both? And also I’m new to these newer ones, so how do I use either of them?

im pretty sure linear velocity should be used for the knockback and also read the api to know how to use them

and pretty sure align orientation only deals with orientation and cant make a knockback

For a knock back, use BasePart:ApplyImpulse. For a player, the impulse must be applied by a Server script…

-- optional, make player fall down
player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.FallingDown)
-- knock-back
local part = player.Character.PrimaryPart
part:ApplyImpulse(-part.CFrame.LookVector * part.AssemblyMass * 35)

Sorry for late reply, how do I know when the impulse ends to change the state back to normal? Also, this just didn’t have an effect on the player, and had no errors, any help?

It’s a one-off effect- all the impulse is applied in one frame. It’s not a continuous force or acceleration you turn on and off.

(edit) oh I see what you mean. The cheap way would be just set it back after n seconds, the better way woud be watch the player’s velocity and set it back when it gets close to 0.

Oh, alright, how do I make it longer?

How exactly do I watch the player’s velocity?

Found out how to make a knockback using AssemblyLinearVelocity. Set the players velocity on the HumanoidRootPart to Vector3.new(100,100,100) then it will create a knockback, and to end the knockback set the velocity back to Vector3.new(0,0,0).

As others have said, an impulse is an instantaneous force, there is nothing to turn off. Also, the falling state automatically resolves when the player hits the ground (they will automatically stand back up). In order for the impulse to work (on a Player) it must be applied via a Server Script. if you try to apply it with a Local Script it will do nothing. All body movers only work when the network owner applies the force.