Hey,
im pretty new to python too but wouldnt you need to use a switch or something?
if space positive would only evaluate true while your pressing space i think, might be other ways to play with triggering modes. you could prob do this using logic bricks but would be good to code i suppose. hope this helps
Okay I got this working using properties. Here’s my code if anyone’s interested:
def jump():
movespeed[2] = 1000
owner["jumpDetect"] = owner["jumpDetect"] + 1
#Reset the jump if you touch the ground
if floorTouch.positive:
owner["jumpDetect"] = 0
#Detect whether jump has been pressed and if it's enabled
if space.positive and owner["jumpDetect"] == 0:
jump()
elif space.positive and owner["jumpDetect"] == 1:
pass
You can use the has_key method to create a property and give it a default value. For example:
# check if the property exsists
if owner.has_key("jumped") == False:
# If it doesn't exsist create it and give it a value
owner["jumped"] = 0
The first time the script runs the property jumped won’t exsist so it’ll get created and assigned a default value, in this case 0. Next time the script loops through its self has_key will return True so the propertie’s value won’t be reassigned back to 0.
Hope you got it working, as i know enough to spot errors but im still terrible with python syntax, trying to work on my C++ skills i would have thought a property would be the way to go though, unless theres a specific command for assigning/switching variables. I might have to use that some time, will be a while though as im working on AI and art for my game.
Just curious (ive already posted a thread about this) but do you know if animated material settings and real time uv properties are working in GE as i think theres a bug.
Happy blending