Why doesn't this work?!

I have two ‘skyboxes’. One is set at location 0,0,0 the other is set at 20,20,0. I want the camera (at the receiving of a message) to jump from the first location to the second. Its frst location is also 0,0,0. Now i have just started learning python. This following script runs, i see the second skybox for a flash, then everything goes black and stays black. The camera is a child of an empty, so i run this script through the empty to the Loc actuator under empty.

cont = GameLogic.getCurrentController()
own = cont.getOwner()

locx = 0
locy = 0

loc = cont.getActuator(“Loc”)
loc.setDLoc((locx + 20),(locy + 20),0,0)
GameLogic.addActiveActuator(loc,1)

Any ideas whats happening?

hey.

cont = GameLogic.getCurrentController()
own = cont.getOwner()

locx = 0
locy = 0

own.setPosition(locx+20,locy+20,0) ?

or

own.setPosition([locx+20,locy+20,0]) ?

^can never remember which. :frowning:

Think that should do ya.

cont = GameLogic.getCurrentController()
own = cont.getOwner()

locx = 0
locy = 0

loc = cont.getActuator("Loc")
loc.setDLoc((locx + 20),(locy + 20),0,0)
GameLogic.addActiveActuator(loc,1) 

As blentagain said use:

cont = GameLogic.getCurrentController()
own = cont.getOwner()

locx = 0
locy = 0

own.setPosition((locx + 20),(locy + 20),0) 

You were using a motion actuator, you can’t set an objects position with a motion actuator…it’s used for motion.
own.setPosition( x, y, z )

Thanks! that makes sense. I just finished the beginners tutorial, so now i’m starting to go thru the ones on these forums that are relevative to blender.

rather than having locx and locy set to 0, is it possible to get it to look at the position xyz assign x to locx and y to locy?
edit…
which i have done but…

cont = GameLogic.getCurrentController()
own = cont.getOwner()

loc = own.getPosition()
locx = loc[0]
locy = loc[1]

own.setPosition([locx + 20,locy + 20,0])
print own.getPosition()

The print out in the console shows it goes from 0,0,0 to 20,20,0 but the actual movement observed is 40,40,0 it doesn’t stop when i want it too :-?

Any ideas? :slight_smile:

not too sure if this is what you getting at but…

youve got own.getOrientaion() too. If you just want the last cams Orientation. Use that?

Sorry, haven`t got a clue how to be able to look in a specific direction using python myself. :frowning:

cont = GameLogic.getCurrentController()
own = cont.getOwner()


loc = own.getPosition()
locx = loc[0]
locy = loc[1]


own.setPosition([locx + 20,locy + 20,0])
print own.getPosition() 

The script gets an objects position then offsets it by 20.
What are you using for the sensor to activate the script? Unselect the button in the sensor that looks like [ ‘’’ ], by default it’s on for the always sensor. It sets the sensor to true pulse mode, it runs at the frequency you set (default 0, thats every frame). Turn that off and it runs only once, offsetting the object only once.
Hope that helps. ^^