I have an object with IPO rotation recorded. I am trying to control it with the objects properties.
I have this script that is supposed to ramp the mouse movements of the X and Y coordinates to the objects x and y properties.
For some reason the script does not seem to be changing the properties .
import Rasterizer
co=GameLogic.getCurrentController()
ob=co.getOwner()
s1=co.getSensor("mouse")
x=s1.getXPosition()
y=s1.getYPosition()
if x>32000:
x=0
if y>32000:
y=0
ob.x=x*100/Rasterizer.getWindowWidth()
ob.y=y*100/Rasterizer.getWindowHeight()
It is to control the top of my player’s rotation. (sort of like a tank turret)
When I move the mose on the X axis i want it to change an integer property called X, when i move Y i want it to add or subtract from the Y property. That way I can control the IPO frames with the action actuator.
That code is all wrong , lol … If you are trying to get that to work in Blender 2.5+ you need to import bge and the default name of the mouse sensor is Mouse not mouse … Caps need to match exactly … I’m not even good at scripting but i can tell it won’t work like that in Blender 2.65. Try something like this:
notice how mouse sensor gives you a normalized list of [x,y] and that means that the values go between 0 and 1 , so 0.5 means center of the screen … that also means that the next part of the code is checking for the wrong range of values … x and y will never reach values of 32000 , lol … the next part of code after that is all wrong again, because of 3 different reasons … your object has no property called x anywhere unless you create one and the call to get window width and height is: