# rotate by position of mouse??

ok I was searching and couldn’t find so I am, gonna ask. is there any way to make an object rotate with the mouse. otherwise make the object keep facing the mouse.
oh.:: and just to ask a Q real fast how do I make the mouse cursor visible–(haven’ t searched for this tough).

Heres a script to show the mouse.

import Rasterizer
Rasterizer.showMouse(1)

I don’t know how you would rotate an object with the mouse tho.

“import Rasterizer
Rasterizer.showMouse(1)” dosent work for me is there another way to show the mouse cursor?

k thanks ima try that later,
hope I could get the rotation though.:o

What is this for, a cannon or something?

You’ll need a script that reads the mouse coordinates from the Rasterizer and runs an IPO on your object.

First set up the IPO curve on your object. Make frame 1 one extreme and a high frame (say 101 for instance) the opposite extreme. Then set up the logic:

Mouse (Movement) >> Python >> IPO (Property)

Write this code for the Python controller:

import Rasterizer

cont = GameLogic.getCurrentController()
own = cont.getOwner()
mouse = cont.getSensor("<i>your mouse sensor name goes here</i>")
followMouse = cont.getActuator("<i>your IPO actuator name goes here</i>")
animLength = 100   ### <i>This is how long the IPO is</i>
winWidth = Rasterizer.getWindowWidth()
xRatio = winWidth/animLength  ### <i>How many pixels wide per frame
</i>
### <i>To find the right frame in your IPO, divide the current mouse
</i>### <i>position by the ratio value.  Add 1, since your end frames are
</i>### <i>1 and 101, not 0 and 100</i>
frame = (mouse.getXPosition()/xRatio) + 1

### <i>Now run the IPO actuator to animate to the right frame.  The
</i>### <i>value of "1" means "True" or "Turn it on."  0 is false/turn off.</i>