Comments and answers for "Calculate time to destination taking account current speed, also how to determine distance between two objects?"
http://answers.unity.com/questions/1541780/calculate-time-to-destination-given-its-speed-also.html
The latest comments and answers for the question "Calculate time to destination taking account current speed, also how to determine distance between two objects?"Comment by no00ob on no00ob's answer
http://answers.unity.com/comments/1541816/view.html
Thank you kind person! :)Mon, 13 Aug 2018 19:13:52 GMTno00obAnswer by MT369MT
http://answers.unity.com/answers/1541794/view.html
Hi, I created this script that calculates the Distance between two objects (That i called Object1 and Object2) using the Vector3.Distance function. To know the Time to reach the object (supposing that only Object1 will move) simply use the formula: *Time = Distance / Speed*.
public GameObject Object1;
public GameObject Object2;
public float Distance;
public float TimeBetweenObjects;
public float Speed;
void Update()
{
Distance = Vector3.Distance(Object1.transform.position, Object2.transform.position);
TimeBetweenObjects = Distance / Speed;
Object1.transform.position = Vector3.MoveTowards(Object1.transform.position, Object2.transform.position, Speed * Time.deltaTime);
}Mon, 13 Aug 2018 18:12:57 GMTMT369MT