Double Tap to Run/Sprint

indentation error means you are missing a tab or space.
your script does not have the proper structure

it should look like this:


from bge import logic, events


owner = logic.getCurrentController().owner
scene = bge.logic.getCurrentScene()
armature = owner.scene.objects['PlayerRig']




move = 0
delay = 10
cool = 10


key_none = logic.KX_INPUT_NONE
key_tap = logic.KX_INPUT_JUST_ACTIVATED
key_active = logic.KX_INPUT_ACTIVE


UPARROWKEY = logic.keyboard.events[events.UPARROWKEY]


## Tap Counter ##
if UPARROWKEY == key_tap:
    owner["TAP"] += 1
	if owner["TAP"] >= 2:
	    owner["TAP"] = 2
	    owner["TIMER"] = 0
	    owner["RUN"] = True


## Double Tap Timer ##
if owner["TAP"] == 1:
    owner["TIMER"] += 1
	if owner["TIMER"] > delay:
	    owner["TIMER"] = 0
	    owner["TAP"] = 0


## Move ##
if UPARROWKEY == key_active:
    armature.playAction("PlayerWalking", 1, 9)
    move = -0.06
    
	if owner["RUN"] == True:
	    move = -0.2   
## Reset Walk Cool Down ##
elif UPARROWKEY == key_none and owner["TAP"] == 2:
    owner["TIMER"] -= 1


	if owner["TIMER"] < -cool:
	    owner["TAP"] = 0
	    owner["TIMER"] = 0
	    owner["RUN"] = False


owner.applyMovement((0,move,0), True)

Wait, I might be missing something. Am I suppose to connect an action actuator?

armature = scene.objects[‘PlayerRig’]

deleted the “owner.”

No, playAction() will replace that brick

just look at my sig, first line, and report the errors here.
or simply make a demo file and upload it, so we can check it.

@MarcoYolo: it is completely normal to need help with things…but I really suggest you start with some simpler scripts…if you are not able to figure this one out, you need to go learn some scripting basics…it is not difficult…anyone can code, not everyone can code well(I’M REFFERING TO ME :))…oops damn caps

You may also want to stick with just bricks at first...I have been using bge now going on 4 months?...I'm really not sure how long.... and I am still figuring things out.

Here’s a sample file, it’s basically a cube parented to an armature.

DoubleTap.blend (581 KB)

All elements should be the same. Note that the armature contains script.

Ok as expected some spaces in fron of tabs can mess up the script, just replaced every line for you.
after that next error comes up, bge not defined. that is due to you import logic from bge, so using bge.logic wont work.

removed the scene line, as i said you dont need to grab the scene, i know he told you to get rid of it, but still you dont need it so removed it.

also i said armature.playAction you used own.playAction fixed that as well (own in this case is not bad, but you dont want the script hanging on the armature)

fixed blend:
DoubleTap (1).blend (580 KB)

#edit
normally you parent your mesh to armature, then you create a bounding box, then parent the armature to the bounding box, and on the bounding box you place all the scripts. and all physics (collision bounds, dynamic type, etc) and you set the mesh + armature on no collision.

Well thanks! I couldn’t figure out what was happening. I also didn’t realize I was supposed to use armature.playAction() instead of own.playAction()

I forgot to remove the scene line. I also tried fixing the tabs and spaced but to no avail.

I also don’t know where bge.logic came from

Well thanks for helping me out. It means a lot…

I also don’t know where bge.logic came from

Well thanks for helping me out. It means a lot…

Np, you had it in the scene line.

Oh, I didn’t see that. This makes me realize how sensitive scripts can be…

has nothing to do with sensitive.

you do:
from bge import logic

so using bge.logic wont work, you need to call logic on its own.

python is indeed indent sensitive, just look at it this way, a function, an if statement and while/for loops are basically containers. If you want them to use some sort of code you need to indent it, so a single tab wil place the code into that container.

good:


if 'a' != 'b':
    print(inside the if statement)

wrong:


if 'a' != 'b':
print(outside the if statement)

and in your case ‘move = -2’ was outside the statement

So I have a quick problem. So everytime I start to run, it doesn’t stop running.

featuring idle, walk, and run animations

Attachments

DoubleTap_Daedalus.blend (514 KB)

Thanks! That definitely fixed my problem. I seriously couldn’t have done it without you guys!