- Home /
Move a specific part of a ragdoll, and the rest of the body follow.
I have a ragdoll, but when it moves it crawls like a reptile, and acts like a ragdoll off course, but with movement.
How can I move only one part (rigidbody) of the ragdoll and make the rest follow it?
I have this section of the script:
ragdoll = transform.FindChild("Armature") as Transform;
rb = ragdoll.GetComponentInChildren(typeof(Rigidbody)) as Rigidbody;
TP_Controller.rb.velocity = MoveVector;
Here is a video of the problem:
Answer by RastaCat33 · Oct 06, 2018 at 04:04 PM
I do not know if it will be useful for you 4 years later but, I think I have the solution...
What I did is create an empty object and when the player is ragdolled, simply put the drag parameter of the rigidbody exactly as the mass and use the function of MovePosition of the Rigidbody class...
Here is the code I wrote for the rigidbody part you want to drag...
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Drag : MonoBehaviour {
public GameObject dragIK;
public bool drag = false;
void Update () {
if (drag) {
GetComponent<Rigidbody> ().drag = GetComponent<Rigidbody> ().mass;
GetComponent<Rigidbody> ().MovePosition (dragIK.transform.position);
} else {
GetComponent<Rigidbody> ().drag = 0;
}
}
}
Hope it helps...
Your answer
Follow this Question
Related Questions
How to make a ragdoll not rotate but still be non kinematic? 0 Answers
Instantiated ragdoll behaves differently than when placed in scene manually 2 Answers
Collision between rigid body zombie characters. 1 Answer
Character - Collider With Scene 0 Answers
Rigidbody+collider conflicts with ragdoll structure 3 Answers