How can I achieve knockback like in battleground games?

  1. What do you want to achieve?

As said in the title.

  1. What is the issue?

I’ve tried constraints, as well as body movers but I can’t seem to recreate the knockback.
I want the knockback to travel the same distance no matter if the character is in the air or not.

  1. What solutions have you tried so far?

I’ve looked through quite a lot of posts but couldn’t find much.

Body velocity, the distance traveled varies if the target is in the air or not, while in The Strongest Battlegrounds the same distance is traveled either way.

Align Position so far has gotten me the closest results, the distance traveled is the same but there’s also an issue with it, if the target is in the air then they will continue flying and wont drop down to the ground until the constraint is disabled.
I use one attachment mode and set the Position property to the front of the character.
(I’m mostly trying to recreate TSB’s dash movement.)

A bit of another question: I’m not sure as to do knockback on the client or server, currently I’m doing everything on the server.
For linear velocity created on the server, the target seems to “teleport” on other client’s screens.

This is my first post on the dev forums, I’d appreciate if I wasn’t left without replies.
Thank you for your time!

3 Likes

You could try using :ApplyImpulse() on the HumanoidRootPart

You’ll need to specify the amount of impulse you want as a Vector3

something like

local char = player.Character
char.HumanoidRootPart:ApplyImpulse(Vector3.new(0,65,35))

2 Likes

I’ve tried to use that on the server side before but nothing happened so I gave up on that method.
Does it not have the issue of the distance traveled being different if the target is in the air or not?

1 Like

Okay, looks like it wont work on the server because of Network Ownership, so you can send a remote event to the client to tell them to Apply the impulse to themselves.

I tested it a few times, and it seemed pretty consistent when testing on myself. You can give it a shot too, just run it in your command bar in studio while in play, and you should be able to see its effects.

Play with the values, i had to use ApplyImpulse(Vector3.new(0,1512,1150)) for mine, but yours can vary. You can also calculate the value you desire based on the player’s mass to get a properly consistent rate

2 Likes

have you tried using AssemblyLinearVelocity? works on the server well, the velocity itself decays overtime

1 Like

I tried it out with the command bar, but I see that the distance still depends if you used it in air or not, this is not what I’m looking for. Thank you for the reply though.

1 Like

The same goes for this too, thank you for the reply. Haven’t heard of this method before though

1 Like

Try using the knockback code from the Steampunk Glove gear.

Source?? I’m interested, it’s something i’ve been struggling too.

knockback(normal combo kbs) like in battlegrounds games
this might seem odd, but they make their knockback on the server using bodyvelocity try it urself

for abilities kb, im sure that its alignposition

2 Likes

To not leave this post without an answer for new devs in the future, I found it a long time ago:

Linear velocity on the client side - works perfect for simple knockback.
(For players! dummies are a different story. And yeah there will be a slight delay because of ping but you can’t really do anything about it)

Here are properties that I use (VectorVelocity changed by script of course):
image

3 Likes

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