22 lines
420 B
C#
22 lines
420 B
C#
using UnityEngine;
|
|
|
|
namespace UltimateWater
|
|
{
|
|
public sealed class CenterOfMass : MonoBehaviour
|
|
{
|
|
public void Apply()
|
|
{
|
|
Rigidbody componentInParent = GetComponentInParent<Rigidbody>();
|
|
if (componentInParent != null)
|
|
{
|
|
componentInParent.centerOfMass = componentInParent.transform.worldToLocalMatrix.MultiplyPoint3x4(base.transform.position);
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
Apply();
|
|
}
|
|
}
|
|
}
|