Previous Thread  Next Thread

chat icon Stop Character Code Doesn't Work

Zoeo

Posted: Fri Jun 15, 2012 3:01 am
Joined: 12 Feb 2012
Posts: 13
I'm VERY new to coding in Blender's python system, infact I've never coded in all my Blender days Confused, but I made a code that would stop my character upon moving in-front of an empties path (Like the Ray Sensors) and i wanted my code to make my character stop moving completely and watch the animations

Code:
from bge import logic
from bge import events as e

def main():
    cam = logic.getCurrentScene().objects["Stephano's Camera"
    stop = logic.objects.events
   
    if 'dStop' in cam:
        if stop[e.RAY] == 1:
            cam['dMove'] reverse(cam['dMove'])
           
def reverse(bool):
    if bool == True:
        return True
    else:
        return False


I based the code off of a code that stops my character upon pressing the toggle button 2, which is kind of annoying and I wish I could change it to when select which character to play as it will automatically make me able to move and use mouselook script, I use a script that allows me to toggle when I can use the mouselook script and make my character move, which is great for my menu since it is inside the same scene as the main game so i can switch characters with the replace mesh logic brick

Here's the code I based it off of:
Code:
from bge import logic
from bge import events as e

def main():   
   cam = logic.getCurrentScene().objects["Stephano's Camera"]
   key = logic.keyboard.events
   
   if 'Enable' in cam:
       if key[e.ONEKEY] == 1:
           cam['Enable'] = reverse(cam['Enable'])

   if 'dMove' in cam:
       if key[e.TWOKEY] == 1:
           cam['dMove'] = reverse(cam['dMove'])

def reverse(bool):
   if bool == True:
      return False
   else:
      return True


Anyone be nice enough to help a guy out Very Happy
Reply with quote


Zoeo

Posted: Mon Jun 18, 2012 4:03 am
Joined: 12 Feb 2012
Posts: 13
No one is going to help me? Sad
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group