Stop Character Code Doesn't Work

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
Zoeo
Posts: 13
Joined: Sun Feb 12, 2012 6:26 pm

Stop Character Code Doesn't Work

Post by Zoeo » Fri Jun 15, 2012 4:01 am

I'm VERY new to coding in Blender's python system, infact I've never coded in all my Blender days :?, 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: Select all

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: Select all

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 :D

Zoeo
Posts: 13
Joined: Sun Feb 12, 2012 6:26 pm

Re: Stop Character Code Doesn't Work

Post by Zoeo » Mon Jun 18, 2012 5:03 am

No one is going to help me? :(

Post Reply

Who is online

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