- Home /
How can I move a rigidbody ragdoll without velocity?
I have this code: TP_Controller.rb.velocity = MoveVector; where the rb stands for an array of child bones that move with the ragdoll.
ragdoll = transform.FindChild("Armature") as Transform; rb = ragdoll.GetComponentInChildren(typeof(Rigidbody)) as Rigidbody;
Instance = this;
animator = GetComponent<Animator>();
rigidbodies = GetComponentsInChildren<Rigidbody>();
int i = rigidbodies.Length;
System.Array.Resize(ref rigidTransforms, i);
System.Array.Resize(ref lastRigidPositions, i);
System.Array.Resize(ref rigidVelocities, i);
System.Array.Resize(ref lastRigidRotations, i);
System.Array.Resize(ref rigidAngularVelocities, i);
i = 0;
foreach (Rigidbody rigidbody in rigidbodies)
{
rigidTransforms[i] = rigidbody.transform;
i++;
}
The problem is that I converted this rigid body character controller to a movevector, but to do that I have to take the velocity of the ragdoll. I want to use another instance that is not rb.velocity. But so far none of the ones like transform.position or so have worked.
Any ideas???
Can you rephrase? I don't even know what converting rigidbody character controller to move vector means? That's two different components converted to a vector? What was your intention again?
I have two scripts, one called Tp_$$anonymous$$otor and the other TP_Controller. This is how TP_$$anonymous$$otor works.
public static TP_$$anonymous$$otor Instance;
public float $$anonymous$$oveSpeed = 20f;
public float Gravity = 10f;
public float Ter$$anonymous$$alVelocity = 20f;
public Vector3 $$anonymous$$oveVector { get; set; }
public float VerticalVelocity { get; set; }
void Awake() // Debe q$$anonymous$$rse en awake
{
Instance = this;
}
public void Update$$anonymous$$otor() // Debe q$$anonymous$$rse en update motor { Process$$anonymous$$otion(); }
void Process$$anonymous$$otion() {
// Transform $$anonymous$$oveVector to World Space
$$anonymous$$oveVector = transform.TransformDirection($$anonymous$$oveVector);
// Normalize $$anonymous$$oveVector if $$anonymous$$agnitude > 1
if ($$anonymous$$oveVector.magnitude > 1)
$$anonymous$$oveVector = Vector3.Normalize($$anonymous$$oveVector);
// $$anonymous$$ultiply $$anonymous$$oveVector by $$anonymous$$oveSpeed
$$anonymous$$oveVector *= $$anonymous$$oveSpeed;
// Reapply VerticalVelocity $$anonymous$$oveVector.y
$$anonymous$$oveVector = new Vector3($$anonymous$$oveVector.x, VerticalVelocity, $$anonymous$$oveVector.z);
// Apply Gravity
ApplyGravity();
// $$anonymous$$ove Character in World Space
TP_Controller.rb.velocity = $$anonymous$$oveVector;
}
void ApplyGravity()
{
if (TP_Controller.Instance.isgrounded == true)
return;
if ($$anonymous$$oveVector.y < -Ter$$anonymous$$alVelocity)
$$anonymous$$oveVector = new Vector3($$anonymous$$oveVector.x, $$anonymous$$oveVector.y - Gravity * Time.deltaTime, $$anonymous$$oveVector.z);
if ((TP_Controller.Instance.isgrounded == false) && $$anonymous$$oveVector.y > -1)
$$anonymous$$oveVector = new Vector3($$anonymous$$oveVector.x, - 12, $$anonymous$$oveVector.z);
}
}
Basicalle I created a Vector 3 called $$anonymous$$oveVector, that manifests in 3 ways $$anonymous$$oveVector.x, VerticalVelocity, $$anonymous$$oveVector.z. But the other script has a ragdoll rigidbody, that controls all the childbones(that I put first). The problem is that I want to move all the bones as a whole, by converting rb wich is all the ragdolls rigidbodies, into $$anonymous$$oveVector. like this TP_Controller.rb.velocity = $$anonymous$$oveVector; but without using velocity.
Have you tried Rigidbody.$$anonymous$$ovePosition yet? http://docs.unity3d.com/ScriptReference/Rigidbody.$$anonymous$$ovePosition.html
Your answer
Follow this Question
Related Questions
Replace player with ragdoll 0 Answers
Moving rigidbodies at random 1 Answer
Implementing Counter-Movement 0 Answers
Disable ragdoll without changing Kinematic boolean? 2 Answers
rigidbody friction problem....HELP!! 1 Answer