Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
avatar image
0
Question by TroyDHX · Aug 08, 2011 at 04:29 AM · transformmathnormalize

Normalise a value

How do I got about normalising a value between 0.0 and 1.0,

For example the values are -3 and 10.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by Blitzerine_1 · Aug 08, 2011 at 06:52 AM

if you want to Lean JS for programming these are tutorials for beginngers :D learn this and you will be able to make these all

125Link Click here125

you can just do

 public class normalize : MonoBehaviour {
 
         Vector2 original = new Vector2 (-3,10);
 
         void Start () {
             print(original.normalized);
         }
     }

you can also use some math operator if you want that if its greater than any number or less than any nummber

 public class normalize : MonoBehaviour {
 
 
   //this means 10 -3 = answer
             Vector2 original = new Vector2 (-3,10);
 
 
 // if answer is greater than 7
             if (new Vector > 7) {
 
 
 // do this..you can add function here what you want if its greater than 7
          print("Answer is greater than 7");
             }
 
 // if answer is less than 7
             if (new Vector < 7) {
 
 
 // do this..you can add function here what you want if its greater than 7
          print("Answer is greater than 7");
             }
     // if answer is equal to 7
             if (new Vector !=   7) {
 
 
 // do this..you can add function here what you want if its Equal to 7
          print("Answer is equal to 7");
             }
         }




If this answer really help you choose this answer ^^

Comment
Add comment · 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
0

Answer by Simon Crowe · Aug 08, 2011 at 06:20 AM

The unity engine only seems to have built-in functionality for normalizing Unity's Vector2, Vector3 and Vector4 types. The example below prints(-0.3, 1.0), the vector (-3,10) with a magnitude of 1.

  public class normalize : MonoBehaviour {
         
         Vector2 original = new Vector2 (-3,10);
         
         void Start () {
             print(original.normalized);
         }
     }

Here it is in the scripting reference: http://unity3d.com/support/documentation/ScriptReference/Vector2-normalized.html I am not sure if this solution will meet your needs, but hope it is of some help.

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Math behind Transform.TransformPoint? 1 Answer

Snapping Connection Points Together Rotation 0 Answers

How to avoid changing transform.parent? 2 Answers

Inefficient transform code. 2 Answers

How to get relative transform between two objects? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges