# Problem with Vector3

Hey guys, can you help me with vectors?

I have 2 points on the ground, A and B. And also i have player which starting position is set to A. I also have a Slider with values 0-100 which represents % of distance between A and B.

So… if Slider is set up to 30, i want my player to move torwards B in 30% of the distance. If i set Slider to let say, 70, i want my player to move further up to 70% of the distance. And if I scale the Slider down for ex. to 23 i want my player to go back up to 23% of this distance.

I have made few attemts on it but it don’t work…maybe you’ll be able to write the code for me?

Best,
Artos

``````Vector3.Lerp(start, end, someValue);
``````

someValue should be 0-1, if you have a 0-100 percent system you can do (percent/100), 0 will return the value of start, 1 will return the value of end, .5 returns a point in the middle, i think you can manage from here on out

2 Likes

Lerp can solve this, as it takes an A value and a B value, then a T value which describes the output value as a percentage between the two.

``````transform.position = Vector3.Lerp(a, b, percent); // percent is between 0...1 not 0...100 so normalize your slider value if you need to
``````

EDIT: TOO SLOW REEEEEEEEEEE

2 Likes