Game Development Community

if(%yVelocity < 0)

by rennie moffat · in Torque Game Builder · 09/01/2009 (7:53 pm) · 4 replies

If I wanted to make this represent x and y. Should X go in the same brackets? A little trouble with this now.



Particularly "and" statements,

for now I am going with


if(%yVelocity <0 && %xVelocity = 0)


About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#2
09/02/2009 (7:47 am)
Hello Rennie,

If I understand you well, you want to check if %yVelocity is lower than 0 and %xVelocity equal to zero. If that is the case, the correct syntax should be :

if(%yVelocity < 0 && %xVelocity == 0) {
 //script goes here
}

The comparison operator is == and not = (check TorqueScript quick reference on TDN at tdn.garagegames.com/wiki/TorqueScript_Quick_Reference).
= is an assignment operator and assign the value you give to the variable (and, if I'm not mistaking, returns a value equal to 1 for true as the assignment didn't cause any error).

Your use of the and operator (&&) seems ok, though.

However, I'm definitely a beginner in programming in general and in TorquScript in particular, so I might be wrong. In that case, I count on the other people here to tell us ;)
#3
09/02/2009 (12:31 pm)
Seb is correct rennie. Just make sure you are using the comparison operator(==) and not the assignment operator(=).
#4
09/02/2009 (12:59 pm)
Yes I simply want to ad in a variable on the x plane. So for now it is just basic coding without a specific <>= ect.


Looking at yours then, minus the == I was correct.


Great, thanks guys.