diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 2d8d1b1..a0469c4 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -6,6 +6,7 @@ [SelectionBase] public class LeafPhysics : MonoBehaviour { private Rigidbody body; + public Rigidbody Body { get { return body; } } // Use this for initialization void Start () { body = GetComponentInChildren(); diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 2d8d1b1..a0469c4 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -6,6 +6,7 @@ [SelectionBase] public class LeafPhysics : MonoBehaviour { private Rigidbody body; + public Rigidbody Body { get { return body; } } // Use this for initialization void Start () { body = GetComponentInChildren(); diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs old mode 100644 new mode 100755 index 1319cb0..94f8801 --- a/FallUnity/Assets/Player/PlayerController.cs +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -28,6 +28,8 @@ // Update is called once per frame void Update () { + Vector3 pos = transform.position; + Vector3 dir = new Vector3(); if (input != null) { @@ -87,6 +89,26 @@ { velY = 0; } + + Vector3 moved = transform.position - pos; + if (moved.magnitude > 0.7f * Time.deltaTime) + { + float radius = 0.6f; + int layer = LayerMask.GetMask("leaf"); + foreach (Collider c in Physics.OverlapSphere(transform.position, radius, layer)) + { + LeafPhysics leaf = c.GetComponentInParent(); + if (leaf != null) + { + Vector3 toLeaf = leaf.transform.position - transform.position; + float dist = toLeaf.magnitude; + float power = Mathf.Pow(1.0f - dist / radius, 2.0f) * Time.deltaTime * 300; + //toLeaf.Normalize(); + toLeaf.y += UnityEngine.Random.Range(0.4f, 1.0f); + leaf.Body.AddForce(toLeaf * (9.0f + UnityEngine.Random.Range(0, 9.0f)) * power); + } + } + } } private InputSource input = null; diff --git a/FallUnity/Assets/Leaves/LeafPhysics.cs b/FallUnity/Assets/Leaves/LeafPhysics.cs index 2d8d1b1..a0469c4 100755 --- a/FallUnity/Assets/Leaves/LeafPhysics.cs +++ b/FallUnity/Assets/Leaves/LeafPhysics.cs @@ -6,6 +6,7 @@ [SelectionBase] public class LeafPhysics : MonoBehaviour { private Rigidbody body; + public Rigidbody Body { get { return body; } } // Use this for initialization void Start () { body = GetComponentInChildren(); diff --git a/FallUnity/Assets/Player/PlayerController.cs b/FallUnity/Assets/Player/PlayerController.cs old mode 100644 new mode 100755 index 1319cb0..94f8801 --- a/FallUnity/Assets/Player/PlayerController.cs +++ b/FallUnity/Assets/Player/PlayerController.cs @@ -28,6 +28,8 @@ // Update is called once per frame void Update () { + Vector3 pos = transform.position; + Vector3 dir = new Vector3(); if (input != null) { @@ -87,6 +89,26 @@ { velY = 0; } + + Vector3 moved = transform.position - pos; + if (moved.magnitude > 0.7f * Time.deltaTime) + { + float radius = 0.6f; + int layer = LayerMask.GetMask("leaf"); + foreach (Collider c in Physics.OverlapSphere(transform.position, radius, layer)) + { + LeafPhysics leaf = c.GetComponentInParent(); + if (leaf != null) + { + Vector3 toLeaf = leaf.transform.position - transform.position; + float dist = toLeaf.magnitude; + float power = Mathf.Pow(1.0f - dist / radius, 2.0f) * Time.deltaTime * 300; + //toLeaf.Normalize(); + toLeaf.y += UnityEngine.Random.Range(0.4f, 1.0f); + leaf.Body.AddForce(toLeaf * (9.0f + UnityEngine.Random.Range(0, 9.0f)) * power); + } + } + } } private InputSource input = null; diff --git a/FallUnity/Assets/XboxCtrlrInput.meta b/FallUnity/Assets/XboxCtrlrInput.meta deleted file mode 100644 index 7b92c68..0000000 --- a/FallUnity/Assets/XboxCtrlrInput.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 03c20217de43a304b9db30d8f9cf01af -folderAsset: yes -timeCreated: 1572134146 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: