How to Use Vector3 value in <b>if X < > 0 then</b> function

Hi all!

I need to know when a car is drifting or not. I was wondering, How do Isolate a value fromt the string that the following variable makes?

var drag = Vector3.Scale(dragMultiplier, relativeDrag);

It returns strings like (-0.1, 0.0, 0.0), or when drifting (-27.0, -0.1, -67.5). I noticed, every time the middle value changes from 0, the car is drifting. How can I put that value in a “if value < > 0 then” function in Javascript? Do I even need to isolate the value? And, how do I declare the resulting variable so I can use it in another script on the same gameobject?

Thanks in advance!!

The middle value is the Y element. You can use this:

var drift: boolean = false;
var yOnly: float = 0;

function Update(){
    ...
    var drag = Vector3.Scale(dragMultiplier, relativeDrag);
    yOnly = drag.y;
    drift = Mathf.Abs(yOnly)>0.01; // sets drift to true when yOnly > 0.01 or < -0.01
    ...
}

To read any variable of this script in another one of the same game object, you can use this:

... // substitute ScriptName by the real script name (without quotes or extension)
    ScriptName var script = GetComponent(ScriptName);
    if (script.drift){ // you can use all variables with the script reference
        ...