restrict in y axis

ok i was wondering how to restrict to an axis i type in
Sphere.locY = 0 (the part of the code)
then i set the python file as a controller and it doesn’t work
is python in BGE different from da modeling part of blender?
just wanted to know how to restrcit y axis

You’ll need to use setPosition. You get the sphere as the owner of a python controller from a sensor.


cont = GameLogic.getCurrentController()
owner = cont.getOwner()
pos = owner.getPosition()
owner.setPosition([pos[0], 0.0, pos[2]])

The GameLogic functions are here:
GameLogic

Just use the “Constraint” actuator instead of Python. Set up the logic like this:

Always >> AND >> Constraint: Y, 0

omg tanks guys both of you.
oh and i just wanted to practice my .py.