 # getLinearVelocity() not working?

For some reason the getLinearVelocity() is not working… the way I want it to. I think it may be my this < this(): but idk…

``````# get the controller
cont = GameLogic.getCurrentController()
own = cont.getOwner()

# get the object actuator named act
actMotion = cont.getActuator("act")

# get velocity
speed = own.getLinearVelocity()
equal = 2

if speed &gt; 1():
own.linv = equal
``````

.getLinearVelocity() get an array (or list?) of 3 elements, not only 1 (separated XYZ velocities).

In other words you should do:

totalSpeed= sqrt (pow(speed,2)+pow(speed,2)+pow(speed,2))

if totalspeed<1:

Or something like that.

sqrt and pow are used to calculate trigonometrically the speed.

sqrt means square root, and pow means power (number, exponent). Square roots and powers are only basic algebra, not trig. and that’s just a simple formula, so don’t feel overwhelmed.

Remember to import math module for using those functions!
You can use ** for replacing pow without the math module in Python.

I’ve used get linear velocity before, i don’t need math. I just need to see if the y value is higher than a certain value.

oh, well you should have mentioned the Y value part.

``````# get the controller
cont = GameLogic.getCurrentController()
own = cont.getOwner()

# get the object actuator named act
actMotion = cont.getActuator("act")

# get velocity
speed = own.getLinearVelocity()
equal = 2

if speed &gt; :
own.linv = equal
``````

there. I changed speed to speed, and took away the parentheses, because that is not a function.

I’ll try that.