Trying to learn some Python, so I’m making a game with a ball (yeah, that’s an original idea, huh?)
Anyway, I have a ball and it moves with the arrow keys using this script, which is not completely mine, I had help in another thread to get it right:
import GameLogic contr=GameLogic.getCurrentController() owner=contr.getOwner() sensors=contr.getSensors() actMove=contr.getActuator("actMove") up=contr.getSensor("up") down=contr.getSensor("down") right=contr.getSensor("right") left=contr.getSensor("left") xValue = 0.0 yValue = 0.0 if up.isPositive(): xValue = 2.0 if down.isPositive(): xValue = -2.0 if right.isPositive(): yValue = 2.0 if left.isPositive(): yValue = -2.0 actMove.setForce(yValue,xValue,0.0,0) GameLogic.addActiveActuator(actMove,1) GameLogic.addActiveActuator(actMove,0)
I also have a hat for my ball, which is attached to the ball by vertex parenting.
Then the camera is parented to the hat.
I have another script which uses the AKEY and DKEY to rotate the hat, which in turn changes the view from the camera.
But then when I use the up arrow to move the ball, it doesn’t go up on the screen(away from the camera), it keeps going in the direction that up was before the view changed.
So I’ve tried turning the Local Transformation on and off for the ball, but neither way will make up continue to move away from the camera regardless of the view.
Any suggestions for this?