Smoothing out :ApplyImpulse() on server owned NPCs

Hi there! I’m experiencing an issue I don’t know how to solve. I have some very basic NPCs which will be an important part of the game I’m working on. When I shoot them using a gun it will ragdoll them if their health reaches 0. Thats where the problem comes, in order to make it a more dynamic action I do a server sided :ApplyImpulse() if the hit character is a Non-Player (Otherwise it handles the velocity locally).

Result of the Applied Impulse is a delay and then the expected result.
(I’ve tested this in the roblox client to make sure its not just some studio issue)

Here is the code snippet responsible for the impulse:

local Backwards = (BulletOwner.Character.PrimaryPart.Position - TargetInstance.Position).Unit*(-175 * 2)
local Force = Humanoid.MoveDirection.Magnitude > 2 or Backwards
Ragdolling:Ragdoll(TargetCharacter, Force) -- Does not yield, If force argument is present then it does not apply any velocity
local Player = Players:GetPlayerFromCharacter(TargetCharacter)
if Player then
   -- Local handling here
   TargetInstance:ApplyImpulse(Force * TargetInstance:GetMass())

– Note: The NPCs are server sided on purpose because if an exploiter gains their network ownership then it would impact everyone else’s gameplay. These NPCs will spawn naturally so they can be killed by players.

– TL:DR: trying to remove the initial delay before they got flung out

Edit: No, there isn’t anything delaying it before the :ApplyImpulse()

1 Like

I’ve resorted to giving network owner to the player that shot the NPC and they fling the NPC on client.

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