(Probably Basic) Python Questions.

Thanks for all the help! Its nice to read the different comments to see how different people go about it. Right now my script looks like this

import bge
from bge import logic
logic = bge.logic
cont = logic.getCurrentController()
own = cont.owner
up = cont.sensors['up']
down = cont.sensors['down']
left = cont.sensors['left']
right = cont.sensors['right']
move = cont.actuators["move"]


if up.positive:
    move.dLoc = [0.0, 0.0, 0.02]
    cont.activate(move)
if up.status == 3:
      cont.deactivate(move)
if down.positive:
    move.dLoc = [0.0, 0.0, -0.02]
    cont.activate(move)
if down.status == 3:
      cont.deactivate(move)
if left.positive:
    move.dLoc = [-0.02, 0.0, 0.0]
    cont.activate(move)
if left.status == 3:
      cont.deactivate(move)
if right.positive:
    move.dLoc = [0.02, 0.0, 0.0]
    cont.activate(move)
if right.status == 3:
      cont.deactivate(move)

Its working the way i want it to, so thank you all very much! Also the game is 2d, which is why when you press w or s you move on the Z axis.

applyMovement
This is nothing else then

gameObject.localPosition += [x,y,z]

is not so (unlesss is changed in the new version)
applyMovement has as reference the matrices of the gameobject itself

localPosition has as reference the matrices of parent, if exist, otherwise is as use worldPosition.

to simulate applyMovement(xyz,local=True)
need this :

own.worldPosition += own.worldOrientation * Vector(xyz)

that is not so handly

It is a position/location change too. The change will be performed by the controller rather than an actuator. It runs exactly one time. Which means the Python controller needs to be triggered every time the change should be performed.

When you use an actuator the actuator will run until you deactivate it. (BTW. your code in post#1did not deactivate the actuator when no key was pressed :wink: = positional change never stopps. )

exactly for that is extraredundant use motion actuator .

you need to activate, set, deactivate , a bounch of code redundant .

using applyMovement() not there any “activation” or “deactivation” , simple you want move -> move .
otherwise implicitely mean do nothing (not need other line to deactivate anything)

indeed this has sense for bricks (since is managed internally without give annoyng),
i mean has any sense for python .

as result using using motion actuator from python(python as filòter toxic) need triple code that need instead with applyMovement