Video here: Reddit - Dive into anything
Hi, trying to make a ragdoll copy the position of an animated skeleton with strength lerped by a pin float so that it can react to external forces (bullets, projectiles) while still maintaining animation. It works great when the skeleton isn’t animated but when it is it seems to break. Animated skeleton has no colliders. I’m not sure why this happens.
Tried:
Setting colliders on the ragdoll to kinematic, same result
Setting colliders and rigidbodies on ragdoll to ignore its own layer, same result
PuppetMaster plugin - seems to break as soon as the pin is less than 1. Setting regain pin speed and collision resistance to 10000 only partially solved this
Code:
public float _pinStrength;
[SerializeField] List<Rigidbody> _myRb = new List<Rigidbody>();
[SerializeField] List<Rigidbody> _yourRb = new List<Rigidbody>();
private void Start()
{
_pinStrength = Mathf.Clamp(_pinStrength, 0, 1);
for (int i = 0; i < _myRb.Count; i++)
{
_myRb[i].gameObject.layer = 12;
_myRb[i].GetComponent<Collider>().excludeLayers = LayerMask.GetMask("EnemyAnimCollider");
_myRb[i].excludeLayers = LayerMask.GetMask("EnemyAnimCollider");
}
}
private void FixedUpdate()
{
for (int i = 0; i < _myRb.Count; i++)
{
_myRb[i].velocity = Vector3.Lerp(_myRb[i].velocity, _yourRb[i].velocity, _pinStrength);
_myRb[i].transform.position = Vector3.Lerp(_myRb[i].transform.position, _yourRb[i].transform.position, _pinStrength);
_myRb[i].gameObject.transform.rotation = Quaternion.Lerp(_myRb[i].gameObject.transform.rotation, _yourRb[i].gameObject.transform.rotation, _pinStrength);
}
}
If there’s another way to go about achieving this effect pls let me know