summaryrefslogtreecommitdiff
path: root/Assets/ProFlares/DemoScripts/AddForceToTarget.cs
blob: 317977308456dfe89888b8f8c697a26f4760c4da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
		
	}
}
}