Slider representing player's movement
Hello guys I'm trying to make a link between a character's position in relation to point A or B so it desplays on the UI slider, basically like in the game Doritos Crash Course.
There is little to no documentation available. Here is a photo of the reference to that game http://wscont2.apps.microsoft.com/winstore/1x/43849969-5c32-423f-b120-7ab321968740/Screenshot.121003.1000000.jpg
If you could please help me out on the scripting it woud be very helpfull. Thanks!
Answer by VesuvianPrime · Aug 21, 2015 at 08:13 PM
Given pointA, pointB and pointPlayer you could do something like:
float aToPlayerMag = (pointA - pointPlayer).magnitude;
float bToPlayerMag = (pointB - pointPlayer).magnitude;
float total = aToPlayerMag + bToPlayerMag;
float delta = aToPlayerMag / total; // A value between 0-1
You could then plug the delta into a UI scroll bar to represent player progress.
But when I place the Vector3 public variables in the inspector how do I link the movement of the player with the Vector 3 points? Also the delta statement shows an error that is assigned but the value is never used. Thanks a lot for the help!
Your answer
Follow this Question
Related Questions
Multiple Sliders act as one. 1 Answer
Unity UI slider seems to increment in random whole number values. Need advice please 0 Answers
Problem with Slider 1 Answer
Prefab UI Slider misses the fill and background items... 0 Answers
How to change the render distance with a slider like in Minecraft? 0 Answers