global object movement in the game engine

So, I’m wondering if there is a good way to move an object using global coordinates, not local movement in the game engine.

I have a joystick block bringing X,Y,Z into a python script (or that’s what I think I should do)

when i hit x-max on my controller, I want my object(let’s call it jim) to move all the way to the max X coordinate. (say 10)

Then , when I pull my controller back to the x-min, I want jim to move with my controller back to x min. Same for y and z.

Now, I think I could do this with three action blocks. each action block would reference a action where i moved and keyed my object at a max and min in that direction… and

I would simply use the actuator - action: property – and a game property like xpos - to define the frame I want to move the object to.

Then my python script would just need to turn my joystick input into a frame number to call in that action block.

Is this really the only way to do it, or the best way? I don’t want to over-complicate things.

If this works, I will have one of the coolest toys ever =)

Did you mean something like this?

Attachments

JoystickPosition2.blend (447 KB)

I actually tried my way, and was unable to make it work, and was having huge issues… and then found the worldPosition thing, and wrote a script exactly like yours… so now I’m definitely sure I’m doing it correctly!! (if only I’d checked here sooner. )
Thanks!


import bge


    cont = bge.logic.getCurrentController()
    own = cont.owner
    
    #joy is the hydra input data. x,y,z loc and x,y,z rot
    joy = cont.sensors['joystick']
    
    #pull the proper joystick channel out of the list, 
    #and assign it to the property control channel and give it a range of 1-10
    px = (joy.axisValues[0]/6553.6) #side to side max +/- 10
    py = (joy.axisValues[1]/6553.6) #front 2 back
    pz = (joy.axisValues[2]/6553.6) #up 'n' down 
    
    print(px,py,pz)
    
    
    own.worldPosition = [px, py, pz]