Be a Supporter!

Help with Python!

  • 205 Views
  • 1 Reply
New Topic Respond to this Topic
Polioman
Polioman
  • Member since: Jul. 6, 2006
  • Offline.
Forum Stats
Member
Level 14
Programmer
Help with Python! 2013-07-09 22:17:50 Reply

I'm using Blender btw.

This right here is my script, and I'm copying it right from a video I'm watching, but I checked every variable and everything should be fine, except that when I try to call this script inside the controller built-in Blender, it does nothing:

from bge import logic, events
from mathutils import Vector
from time import clock

class G:
    mouse = logic.mouse
    keyboard = logic.keyboard
    
    
def mouse():
    G.player.applyRotation((0,0,-(round(logic.mouse.position[0],2)-0.5)), True)
    G.cam.applyRotation((-(round(logic.mouse.position[1],2)-0.5),0,0), True)
    logic.mouse.position = 0.5, 0.5
    
def launch():
    control = logic.getCurrentController()
    if logic.mouse.events[logic.KX_MOUSE_BUT_LEFT] == logic.KX_INPUT_JUST_ACTIVATED:
        G.startclock1 = clock()
    elif logic.mouse.events[logic.KX_MOUSE_BUT_RIGHT] == logic.KX_INPUT_JUST_ACTIVATED:
        G.startclock2 = clock()
    elif logic.mouse.events[logic.KX_MOUSE_BUT_LEFT] == logic.KX_INPUT_JUST_RELEASED:
        addobj = control.actuators["Edit Object"]
        addobj.linearVelocity = (-1,(20*(clock() - G.startclock1)), 0)
        control.activate(addobj)
    elif logic.mouse.events[logic.KX_MOUSE_BUT_RIGHT] == logic.KX_INPUT_JUST_RELEASED:
        addobj = control.actuators["Edit Object1"]
        addobj.linearVelocity = (-1,(20*(clock() - G.startclock2)), 0)
        control.activate(addobj)

Can anyone please be so kind to tell me what's wrong with my code?


..::: AS3: Little Essay :::....:::AS3: Programming Sex:::..
||Nosejobs only result in bigger noses.||

Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Help with Python! 2013-07-10 02:51:33 Reply

Which version of Python are you using?
Do you receive any errors?
What is supposed to happen that doesn't?