diff options
Diffstat (limited to 'Assets/ProFlares/DemoScripts/AddForceToTarget.cs')
-rw-r--r-- | Assets/ProFlares/DemoScripts/AddForceToTarget.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Assets/ProFlares/DemoScripts/AddForceToTarget.cs b/Assets/ProFlares/DemoScripts/AddForceToTarget.cs new file mode 100644 index 0000000..3179773 --- /dev/null +++ b/Assets/ProFlares/DemoScripts/AddForceToTarget.cs @@ -0,0 +1,27 @@ +/// ProFlares - v1.08 - Copyright 2014-2015 All rights reserved - ProFlares.com + +using UnityEngine; +using System.Collections; +namespace ProFlares { +public class AddForceToTarget : MonoBehaviour { + public Transform target; + public float force; + + public ForceMode mode; + + void FixedUpdate () { + + + float dist = (Vector3.Distance(transform.position,target.position)*0.01f); + + + Vector3 dir = target.position-transform.position; +#if UNITY_5_0 + GetComponent<Rigidbody>().AddForce(dir*(force*dist),mode); +#else + GetComponent<Rigidbody>().AddForce(dir*(force*dist),mode); +#endif + + } +} +}
\ No newline at end of file |