Question by
PedroBitencourt · Nov 20, 2020 at 10:58 AM ·
physicsrigidbodyragdolldynamics
How do I get a ragdoll to hold a moving object with his hands?
I can't find much material about it on the internet, the object that the character holds is moving on the x and y axes
ragdoll.png
(9.9 kB)
Comment
Best Answer
Answer by PedroBitencourt · Nov 23, 2020 at 10:53 AM
I did it
public void ChangeToTarget(Vector3 target)
{
if(body != null)
{
if(body.constraints != RigidbodyConstraints.None)
body.constraints = RigidbodyConstraints.None;
Vector3 direction = (target - body.transform.position);
Vector3 toVelocity = direction.normalized * (speed * targetDistance) / body.mass; //mm p dist
body.velocity = toVelocity;
}
}