48 lines
886 B
C#
48 lines
886 B
C#
using RootMotion.FinalIK;
|
|
using UnityEngine;
|
|
|
|
public class FFishRagDoll : MonoBehaviour
|
|
{
|
|
private Transform TailRag;
|
|
|
|
[HideInInspector]
|
|
public CCDIK _ccidk;
|
|
|
|
private void Start()
|
|
{
|
|
_ccidk = GetComponent<CCDIK>();
|
|
TailRag = _ccidk.solver.target;
|
|
_ccidk.enabled = false;
|
|
if (TailRag == null)
|
|
{
|
|
Debug.LogError("Ryba nie ma podczepionego TailRag: " + base.transform.name);
|
|
}
|
|
else
|
|
{
|
|
SetupTailRag();
|
|
}
|
|
}
|
|
|
|
private void SetupTailRag()
|
|
{
|
|
SpringJoint component = TailRag.GetComponent<SpringJoint>();
|
|
component.maxDistance = base.transform.localScale.z * 0.2f;
|
|
component.connectedBody = GetComponent<Rigidbody>();
|
|
Object.Destroy(component);
|
|
TailRag.GetComponent<Rigidbody>().drag = 0.2f;
|
|
_ccidk.enabled = false;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (!(TailRag == null))
|
|
{
|
|
Object.Destroy(TailRag.gameObject);
|
|
}
|
|
}
|
|
}
|