• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by rdgorodrigo · Aug 21, 2015 at 07:13 PM · uicharactercontrollerslidervertex

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!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image rdgorodrigo · Aug 24, 2015 at 02:15 PM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to create a difficulty slider/setting for a unity game in a setting scene 1 Answer

How To Make Healthbar Value Slowly Decrease? 1 Answer

Multiple enemy health bars with 3 different sliders and a game manager script 0 Answers

Have UI toggle and sliders trigger sounds? 0 Answers

How to make model stop moving when in a certain zone 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges