- Home /
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.
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 ^^
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172550im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
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