Home > Blockchain >  Unity 3D - Measuring the distance between two gameObjects and converting it on a scale from 0 to 60
Unity 3D - Measuring the distance between two gameObjects and converting it on a scale from 0 to 60

Time:10-22

I have a script that calculates the distance between two gameObjects with Vector3.Distance

How can I increase a number from 0 to 60 gradually as one gameObject gets closer to the other?

CodePudding user response:

Basic maths:

Number = 60/(1 Distance);

When distance is infinity, it returns 0.
When distance is 0, it returns 60.

  • Related