Attempting to fling NPCs and players causing a long pause

There’s a good chance this belongs in #bug-reports:engine-bugs, but I’m not able to post there.

I’ve been trying to fling a character by setting their HumanoidStateType to Physics and applying an impulse/bodyvelocity, to simulate a sort of knockback from an explosion. For some reason, there’s a visible pause when I do this, and it only gets much worse when players are flung (1-2s delay). In the case of an NPC, their network owner is set to nil (such that GetNetworkOwnershipAuto() will return false) upon creation. When flinging the local player (from their client), there is no visible delay. This issue appears to happen both in studio and in-game.

Things I have tried to remedy this:

  • Starting with their HumanoidStateType set as Physics long before they get flung
  • Disabling the ragdoll aspect entirely
  • (For players,) always applying the flinging on the server instead of the client of the network owner
  • Only applying the impulse on everyone’s client
  • Applying the impulse on both everyone’s client and the server

All of which have not made any noticeable difference.

GIF of shooting at the ground, flinging myself (with no delay)
GIF of shooting an NPC, causing a delay
GIF of shooting a player, causing a huge delay

A lot of games (namely Grand Piece Online and Anime Battle Arena) do not have this issue, so evidently there is a fix.

8 Likes

To cause a normal kb, you can just use a simple raycast behind the hit target and set the hrp velocity to the ray - (this kb is used in the games your talking about, I don’t think I’ve seen them use intentional flinging methods)
Also if this isn’t what your looking for, post your script and i’ll take a look, this shouldn’t be a engine bug at all.

This is part of the problem. Setting their velocity (or applying anything physics-related, from what I can tell) causes them to be held in place for a second.

If you want an example of what I’m using to fling someone, here:

self.Character.Humanoid:ChangeState( Enum.HumanoidStateType.Physics )

local BV = Instance.new("BodyVelocity")
BV.Velocity = Force
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Parent = self.Character.HumanoidRootPart

game.Debris:AddItem(BV, 0)

This can also be used interchangeably with ApplyImpulse, as they accomplish similar things. (and still have this same issue)

2 Likes
Target.Velocity =  Root.CFrame.LookVector * 200 + Root.CFrame.UpVector * 40

this is what you want , Root is the player;s root that is firing the weapon, Target is the root of the Player being hit
The only thing I can think of that would cause a pause is not the physics but your ragdoll script probably anchors the humanoidrootpart. Try disabling the ragdoll and tell me if this code works. or a for statment, send me all your code

I know how to apply knockback, that’s not the problem.

My ragdoll script does not anchor anything, all it does is disables Motor6Ds found in the character. As stated in the original post, I tried disabling the ragdoll script, and the issue persisted.

2 Likes

Okay, I’m just gonna run down everything then

IN THE TOUCHED EVENT SCRIPT

coroutine.wrap(function()
Target.Velocity =  Root.CFrame.LookVector * 200 + Root.CFrame.UpVector * 40
end)()
-- place the kb in touched event
-- place ragdoll here if you have it in your touched event

I’m not sure how your doing your ragdoll but it should be done after the kb starts
and you should do the kb method i’ve sent it’s better than using bodyvelocity for numerous reasons

The thing that’s causing delay is probably something go on one of your scripts, but you haven’t posted any of them so I’m here making assumptions.

also coroutine wraps create other threads so if you have anything that loops or waits or pauses the script in any way put it in one of those

Again, I already know how to apply force to someone. As far as I can tell, my ragdoll script isn’t part of the problem, as the delay persisted after disabling ragdoll entirely.

I can assure you it is not a result of any of my scripts, I loaded a fresh studio, attempted to ChangeState an NPC to Physics, and then apply the force, and the issue still persisted.

1 Like

It has been happening to me as well; I assume it’s something they changed with the engine.

Have you tried contacting Roblox staff?

Sorry for the late reply, I just got up.

I haven’t tried contacting staff yet, as I’m not 100% sure if this is a bug or just an issue with my code, and I don’t exactly know where to go to report a bug.

1 Like

I’m having the same issues with the :ApplyImpulse function getting delayed a lot but I noticed that when the applied rig / character is moving, there is no delay.

BasePart:SetNetworkOwner(player) Is how you stop this visual bug, if a player has hit the enemy then set the network owner of the enemies primary part to the player who hit them.

Edit: This may error if any part of the enemy or what it’s connected to is anchored so just pcall it or use a method to check if any of it’s descendants are anchored.

2 Likes

I have been trying to solve this problem for my air combo/slam ground for my combat system, however the lift for the victim character is delayed. I tried the method you said but the problem is that it is still laggy for the victim, which I don’t want. Is there any ways to fix this?

1 Like