Making a controllable ragdoll character

So I’m working on a wacky physics-related game and I’m trying to figure out the best way to make a players character into more of a ragdoll that can still be controlled. I started with EchoReapers ragdoll death script and modified it to only affect limbs, then added some stuff to alter the Transform property of the Root Motor6D attaching the LowerTorso to the HumanoidRootPart to make the torso wiggle around. Which I think looks nice
https://gfycat.com/ThatAcrobaticJanenschia
The trouble I’m having with that is how to make that motion replicate to the server, which can see the limbs moving around but not the Root.Transform changing
https://gfycat.com/VengefulGloriousAzurevasesponge
I tried using a remote event to keep the server updated with the current Root Transformation but it doesn’t happen in sync with the limbs and looks bad
https://gfycat.com/VerifiableHonorableFlatfish
Annnd secondly I keep having issues where various body parts get deleted for reasons I can’t figure out. I can fix this locally with a loop that makes sure all the body parts stay parented to the character, but then the player still sees other characters missing limbs and the same method doesn’t seem to work at fixing other characters (tried on both the server and client). So any advice with this would be greatly appreciated :smiley:

16 Likes

What I’d do is apply the script to each player locally. When you join loop through all players (on the client) and apply the script on said player’s client. When a player joins send an event to all other clients and apply the script to the newly joined player. That way each player has the script running for all the other players (including him/herself) on the client.

I am not sure if this is the best method, but it’s many times better than forcefeeding all clients with update event/function calls.

4 Likes

:thinking: That could work, I’ll try it out

1 Like

Alright I tried that, but I can’t get the limbs to behave now. It looks like theyre still controlled by the other player so they don’t match the torso and it’s kinda the opposite problem from before
https://gfycat.com/UnequaledGleefulCoati
I tried making local copies of the other characters limbs and deleting the originals (is there a better way to make them locally-controlled?) but then they’re just frozen in place
https://gfycat.com/UnhealthyOfficialGordonsetter

1 Like

You need to make the the script use the character of the player it’s attached to. Your issue seems to be that you’re using the same torso for each player, what I meant was that you give each player a copy of the script to animate your character and vise versa.

If there’s 3 players online, Player1, Player2 and Player3.
When you join you loop through all the players online, including yourself, and apply the ragdoll script to the players you’re looping through.

What you could do is have one instance of the ragdoll script per client, and modify it so for each player it animates it on the player’s character respectively.

What you should be doing:
Player1 applies the ragdoll animation on Player1, Player2, Player3 using their torso.
Player2 applies the ragdoll animation on Player1, Player2, Player3 using their torso.
Player3 applies the ragdoll animation on Player1, Player2, Player3 using their torso.

What you’re currently doing is:
Player1 applies the ragdoll animation on Player1, Player2, Player3 using your torso.
Player2 applies the ragdoll animation on Player1, Player2, Player3 using your torso.
Player3 applies the ragdoll animation on Player1, Player2, Player3 using your torso.

1 Like

I’m not sure how you figured that, but I’m doing what you’re saying. When the localscript finds a new character in the game, it applies all the ragdoll stuff to that character and starts altering the Transform property of that characters Root Motor6D. Each character has it’s own thread that doesn’t look at or care about any other characters. The other characters torsos are doing what I want now (locally), but the limbs are still following what the server says they should be doing, so they don’t match. There’s no animations involved although I’m considering moving towards something with animations.

1 Like

Not sure if “the limbs are following what the server says they should be doing” is intentional, but you should move all of the code to the client not just the torso movement.

All the code is clientside, the script moves the torso by altering a Motor6D (which works fine now), the limbs are attached to the torso with constraints, and the limbs are moved around with BodyPositions. The issue is that the server seems to be overriding what the client is trying to do to the limbs, saying “no, the player who owns this character says their limbs are in this other position” and the client does what the server says and puts them there, instead of what the script is trying to do.

2 Likes

Update - I went back to my original setup where the limbs move correctly and the torso doesn’t, and I added a thing that watches where the attachments are between the limbs and torso and tries to move the torso to correct for the differences. I only have it correct the y-axis so far but it seems to work
https://gfycat.com/WelcomeLateAustraliankelpie
The limbs still like to randomly fall off though, which is annoying. They don’t even detach and fall down, they immediately get their Parent=nil for some reason. :confused:

2 Likes