5 using System.Collections.Generic;
12 public Vector3 WorldCenterOfGravity
16 return transform.TransformPoint(LocalCenterOfGravity);
20 LocalCenterOfGravity = transform.InverseTransformPoint(value);
25 public Vector3 AxisStrength = Vector3.one;
27 public float Radius = 0.5f;
28 public AnimationCurve GravityStrength = AnimationCurve.EaseInOut(0, 0, 1, 1);
32 Vector3 target = WorldCenterOfGravity;
34 float normalizedDistance = 1f - Mathf.Clamp01 (Vector3.Distance(point, target) / Radius);
36 strength *= GravityStrength.Evaluate (normalizedDistance);
38 point.x = Mathf.Lerp(point.x, target.x, Mathf.Clamp01(strength * AxisStrength.x));
39 point.y = Mathf.Lerp(point.y, target.y, Mathf.Clamp01(strength * AxisStrength.y));
40 point.z = Mathf.Lerp(point.z, target.z, Mathf.Clamp01(strength * AxisStrength.z));
52 Gizmos.color = Color.red;
53 Gizmos.DrawSphere(WorldCenterOfGravity, 0.05f);
54 Gizmos.DrawWireSphere(WorldCenterOfGravity, Radius);