Pythong Script not Running

Sorry if this isn’t the correct place to put this Post, but I’m having the most horrible time just trying to get a basic Python Script to run. It’s not really a problem compiling, more as it seem that BGE isn’t detecting the script at all, I’m following a tutorial online so sorry if the answer is Obvious and I’m a complete newby. I’ll up load a .blend file I’d really appreciate an explanation thanks guys!
Code Below

import bge

def main():

cont = bge.logic.getCurrentController()
player = cont.owner
keyboard = bge.logic.keyboard

if  bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.UPARROWKEY]:
    #Move Forward
    player.applyMovement((0, .01, 0), True)

main()

Attachments

script.blend (399 KB)

Check true Pulse :slight_smile:

Attachments


Side note, do you have any spiced potatoes?

lol I mixed up your name with this one

Otik Sandeth

Thanks man! that works!

No problem, it’s the really simple stuff that can be the most frustrating,

your going to want to use forces or linear motions or something though, as setLoc does not use physics

player.applyMovement((0, .01, 0), True)

you should edit a motion actuator in real time instead,
or just use logic,

Do you already have a walk cycle?
3rd person or 1st person?
game style?

Well right now I’m just trying to learn how to code in Python, before i tackle on walk cycles and animations (I do have some laying around but i don’t feel like trying to implement them into the game engine at the moment.) But I am having another problem with my Script Right now I’ve gotten the arrow to move and shoot a ball, It works but now I’m trying to make a destructible cube that turns red as its health decreases. Only it won’t work and I’ve COPIED and DISSECTED and tried everything, I’ll post the code below and a blend could really really use the help.

def main():

cont = bge.logic.getCurrentController()
obst = cont.owner
keyboard = bge.logic.keyboard
scene = bge.logic.getCurrentScene()

if 'hp' not in obst:
    start(obst)
#####

obst.color = (1, obst['hp'], obst['hp'], 1)
if obst['hp'] <= 0:
    die(obst)

def start(obst):
obst[‘hp’] = 0.25

def die(obst):
obst.endObject()

main()

Attachments

script2.blend (421 KB)

in logic would be much easier in this case, as you need to use a collision sensor anyway,
“enemy”
property health = 100
Collision Property “bullet”----------------------------------------------------------------------------and----------------property Health Add -10
property sensor interval if health="-60 through 0" (in case multiple hits in one frame) -and------------------Edit End object

in bullet,
Collision with enemy---------------------------and--------------------edit end object
___________________________________---------------------edit add object “impact” 2 frame