Blender Capped Mouselook: 2.48a

This mouselook works perfectly well on Blender 2.48a, and it’s capped. It doesn’t lock like the old IPO mouselook, and the cap seems to be always at the same point; you set it up the same way as in the original one. Enjoy.

# - Mouselook Script

import Rasterizer as r

c=GameLogic.getCurrentController()
o=c.getOwner()

if hasattr(o, 'x')==0:
    o.x=0.0

mouse=c.getSensor("mouse")
lmotion=c.getActuator("leftright")
wmotion=c.getActuator("updown")
sens=0.0006

posx=(r.getWindowWidth()/2-mouse.getXPosition())*sens
posy=(r.getWindowHeight()/2-mouse.getYPosition())*sens

if o.x<=-1 and posy<0 or o.x>=1 and posy>0:
    posy = 0.0
o.x+=posy

lmotion.setDRot(0,0,posx,1)
wmotion.setDRot(posy,0,0,1)

GameLogic.addActiveActuator(wmotion,1)
GameLogic.addActiveActuator(lmotion,1)

r.setMousePosition(r.getWindowWidth()/2,r.getWindowHeight()/2)

I’ve made the script again to make it shorter. It’s only 29 lines now!

Attachments

mouseexample.blend (232 KB)

I’m not sure I exactly understand the benefits of this script as opposed to an ipo based mouse look. What are they more specifically?

If you look at the FPS template now, with 2.48a, at startup the mouselook is locked on an axis, which is really annoying for players, and they may not like the game. They’d think the programmers are lazy if they see they can roll forever…

A little example, maybe?!

I changed thee caps, the lower one was a bit too exaggerated. Both set to 1.0
Example:

Attachments

mouseexample.blend (64 KB)

BUMP - Example done

Dear B3D00
at 02:57 I’m sleeping! :wink:
Anyway, thank you! It works well, but…what’s the difference with the fps template one?
Bye

Oto,
If you open the fps template with Blender 2.48a, you should see that when it starts you can’t move by the Z-axis; this could be annoying for players and give them a bad idea about the game…

thanks, ill use this=)

This is a very smooth mouselook, thanks!

You’re welcome.
I’ve shortened the script!

Hello!
I can use u script in my scenes?
I like much this! very better that Templere walktroug that i was used.
Of couse the credit for this will be you ^^
Bye ^^

Yeah, you’re free to use it however you want, except by saying that is yours directly.

once again, thanks.
i didnt really hope for such an update of this script before.

I love how smooth this is and thanks for all the hard work in scripting. I do have one question though. Any idea how to remove the post movement drifting?

B3D00, I don’t see a mouselook script in this, but aim.py. I assumed that your script was to replace this one, but they have different actuators. Did you add different actuators to yours before writing the script?

Edit: Nevermind, I’m an idiot. I thought this was a page in another topic I was looking at. Thanks for the script, and ignore that previous statement.