Is variable x less than or more than a given value?

NooB

How do I test if variable x is less than or more than a given value??
Does java recognise the operator < or > … I can’t find any reference to them in the unity manual … presumably one can test if variable “x” is less than or more than a given value … so how is it done??

??
//please tell me how I find out! … and then once knowing how do I set x to a new value?

if xspeed < 0.0 {
xspeed = 0.0;
}

this code returns the error … expecting " : " found " = "

what is I s’posed to do??

thanks

The standard comparison operators work < > <= >= != == etc

For what i think you’re trying to do, try the Mathf class - its got lots a useful functions like Clamp, Min, Max etc
It’s here:
http://unity3d.com/Documentation/ScriptReference/Mathf.html

EDIT:
And I’ve just read your code and realized it should be:

if(xSpeed <=0.0f)
{
    DoSomething;
}

Actually, no “f” in Javascript :slight_smile:

if (xSpeed < 0.0) {
//do something
}

Thankyou …

That resolved the issue for me … thus far …

you got me - habit from C# :wink: