Network ownership breaking NPC ragdolls

Hi. I’m wrestling with a problem with my ragdolled NPCs being reset whenever their network ownership is changed to a nearby client (as opposed to being calculated on the server).

This GIF shows the problem of the NPC being rebuilt.
This GIF shows the same scenario but with network owners visualised. You can see how the NPC is rebuilt as soon as I get near enough for the engine to assign my character network ownership.

When the NPC is created (from a clone of the character), I call SetNetworkOwnershipAuto(false) on each part, but after a bit of digging realised that this wasn’t working for whatever reason, as calling CanSetNetworkOwnership() on any of the clone’s parts still returned true.

What can I do to ensure the clone’s ownership stays on the server? Or otherwise how can I stop the clone’s character being rebuilt whenever the network ownership changes?

Cheers.

1 Like

I think setting networkowner to nil sets it to server, not sure though.

What I would possibly do in this scenario, since it’s the player’s own body/ragdoll, always leave network owner set to that player?

Have the player handle their own bodies/ragdolls each to avoid network owners changing and messing it up,
or if ragdolls are a visual thing, you can also just do them on the client, some games actually do ragdolls on the client only as they are purely a visual and serve no other purpose, unless players can interact with ragdolls (ragdolls holding the inventory of a dead player for example) you can just do them on the client, it will spare the server some work too and make it less laggy.

1 Like

I think setting networkowner to nil sets it to server, not sure though.

Yes, it does, and I do, but the engine still gives any nearby clients ownership of the NPC.

What I would possibly do in this scenario, since it’s the player’s own body/ragdoll, always leave network owner set to that player?

The problem is that these are NPCs; there’s no player that owns the character, so by default I leave ownership to the server (again, until an actual player comes near to it, at which point it switches and causes the rebuild).

As for handling ragdolls client-side, I had considered it, but there is a certain level of interaction that needs to take place; they aren’t just visual as the ragdolled character’s aren’t necessarily dead. They may simply be stunned, and so (this is a magic system), they are still liable to further effects.

SetNetworkOwnershipAuto doesn’t take an argument. It will always just set the part to automatically taking network ownership - instead, use SetNetworkOwner(nil)

2 Likes

In that case, maybe set the network owner to the player that stunned/killed the NPC instead, only change it as soon as another player starts to interact with it (like press a button to pick up stunned/dead body).

Or if you want to do it a real fancy way, you could do ragdolls on the client again, but have the server decide where the ragdoll is. Hou have one part on the server with network owner set to nearest player or player who last interacted/stunned the NPC and the client ragdoll is welded/jointed to that part on the server or gets moved towards it with a body position.

This can be very tricky, requires some client/server communication and collision groups but does the job quite well if well executed, optimized too.

Solution was as simple as setting disabling Humanoid.AutomaticScalingEnabled. Didn’t come across this sooner because there’s no official documentation and only found it through the announcement back in 2018.

7 Likes

This really helped! Thank you for posting your solution to this problem

Two years later this answer has ended my several-day-long journey of frustration and endless pain. Thank you, my friend.

1 Like