Smooth knockback on all clients

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make knockback that is smooth and feels good for all players on my game

  1. What is the issue? Include screenshots / videos if possible!

Knockback is janky when first applying

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Looked at a lot of posts on the Dev hub, none of them worked. I tried doing the knockback on the client for the person receiving knockback and it would look good for the person receiving, but for everyone else it would be laggy. I tried setting the network ownership to the person attacking, and it would look good for them but for the person receiving the knockback they would just teleport to the end position. The video I’m about to include has the network ownership set to the server, however.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- Knockback
function Knockback.Push(Target: BasePart, Direction: number, Magnitude: number, Duration: number)
	local Attachment = Instance.new("Attachment")
	Attachment.Name = "PushAttachment"
	Attachment.Parent = Target
	
	local LV = Instance.new("LinearVelocity")
	LV.Attachment0 = Attachment
	LV.VectorVelocity = Direction * Magnitude
	LV.MaxForce = math.huge
	LV.Parent = Attachment
	
	Debris:AddItem(LV, Duration)
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Video of Knockback

1 Like

Just tried using Vector Force, Assembly Linear Velocity, and Body Velocity as well. None have worked.

Did you try applying the knockback on the Server as well as the Client?

Tried both, but in the video it’s applied on the server only.

On both, at the same time, not just one or the other.

Yes, I’ve tried that. Having the server and both clients run calculations at the same time. It is still a little janky for the attacker, however, for the person receiving the knockback it is perfect. Ill attach a video here.

Using Body Velocity on the client and Linear Velocity on the server yielded much better results. still not what I’m looking for though. I’m going to keep looking in case anyone in the future has the same problem as me. If someone has any ideas please reply to this post.

The knockback looks janky because the server does it first, and the player being hit has to wait for that to show up on their screen. The code works fine, but because the client doesn’t react right away, it feels laggy for the person getting knocked back.

I’ve played games on Roblox where this isn’t an issue though. There is 100% a way to get rid of this effect, and that’s what I’m looking for. I understand the problem is due to Server-Client latency issues, however, I’m either trying to find a way to cover it up, or fix it.

You only gave a tiny snippet of your code, and your attitude didn’t really help either. I tried helping with what you gave, but I’m done now. Good luck.

It’s almost as if you could have asked, but it’s fine, I doubt you could have helped anyway.

Right, because being rude and vague really invites help. Enjoy your problem.

Ok. Can’t enjoy it anymore because I solved it. Just use Align Position lol.

Crazy how it took you an hour just to find AlignPosition :sob:.

Yeah, after trying a lot of options I thought of Align Position. Works pretty well. I don’t know if you can give your input though, since you couldn’t even come up with an answer. The only thing you could do before commenting on my “attitude,” was give me information I already knew.

Not to be “that guy”, but please reply to the person you need to and not yourself. I didn’t get any notification of your reply posts because of it.

Sorry about that. New to the forums, but I understand. Thanks for the heads up.

1 Like

your combat system on your portfolio is a free model and the basketball system is from hoops city lol, pls I hope noone ever hires you

Funny how you’re spending your time hating on my portfolio instead of building one of your own. I never said I made those systems from scratch, they were placeholders while I was handling school, work, and commissions. Meanwhile, I’ve worked on games with tens of millions of visits. If that bothers you, maybe focus less on stalking people you’ve never even talked to, and more on actually learning something.

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