- Home /
Finding maximum peak of distance between two moving objects?
Hello everyone,
I have more like programming and logical problem:
While having two objects and calculating distance between them using this:
score = Vector3.Distance(transform.position, target.transform.position);
How to find maximum peak of this variable when for example:
object 1 is moving away from object 2, and then its returning to object 2.
I just need to find its maximum peak. Any ideas?
Comment
If you have the formulas for the movement of the objects you can put all the formulas together and use the derivative to find any maximums or $$anonymous$$imums.
Are you asking just to store the largest distance when you move them? If so, just add something like:
If (maxScore < score) {
maxScore = score
}
Your answer