Serious problems with mouselook script

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Posts: 2
Joined: Sun Nov 25, 2012 12:56 am

Serious problems with mouselook script

Postby ebonygeek45 » Sun Nov 25, 2012 1:18 am


I am not denying that I am a newbie with I need some help. I do have lite programming experience but in other languages and not python.

I am working on a mouselook script from a tutorial that I was trying to follow along with. My goal is to get the mouselook working with a wsad script that I figured out.

I have 2 issues

1. When I get the mouselook working what is the best way to combine it with the wsad script.

2. I am getting an error in my system console that says "Pyton controller found the module but could not access the function - object 'eyes, controller 'python': AttributeError: 'module' object has no attribute 'py'

I was going to try to insert an image of my logic bricks by can't understand how to do it her.

My code for the mouselook that I am having problems with is below.

Code: Select all

from bge import logic, render

class MouseLook:

    def __init__(self, cont):
        self.cont = cont
        self.sen_mouse = self.cont.sensors["mouse"]
        self.act_rotx = self.cont.actuators["rotx"]
        self.act_rotz = self.cont.actuators["rotz"]
        x = render.getWindowWidth()//2
        y = render.getWindowHeight()//2
        self.screen_center = (x, y)

    def getMouseOffset(self):

        vec_screencenter = Vector(self.screen_center)   
        vec_mouseposition = Vector(self.sen_mouse.position)
        return vec_mouseposition - vec_screencenter

    def main(self):
        vec_offset = self.getMouseOffset()

        self.act_rotx.dRot = [vec_offset.y, 0, 0]
        self.act_rotz.dRot = [0, 0, vec_offset.x]
mouse_look = MouseLook(logic.getCurrentController())

def main():

Posts: 2
Joined: Sun Nov 25, 2012 12:56 am

tried a different tutorial

Postby ebonygeek45 » Sun Nov 25, 2012 8:06 am

I am thinking that this script is a little ahead of me for now. I am going with
this tutorial for now until a get a little better.


I used the script from the video and followed the steps in the video for mouselook and it was working right away.

Now all I have to do is figure out how to get it working with my wsad script then I can tackle the next aspect of my game.

Return to “Python”

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests