So I’ve added walking animations for all directions and an idle state. Another feature is being added!
Which means more problems for me…
So the player does the jumping animation but it keeps ascending everytime I hold the spacebar. How do I make this stop?
from bge import logic, events
scene = logic.getCurrentScene()
owner = logic.getCurrentController().owner
armature = scene.objects['PlayerRig']
move = 0
moveSideways = 0
<b>Jump = 0</b>
delay = 10
cool = 10
key_none = logic.KX_INPUT_NONE
key_tap = logic.KX_INPUT_JUST_ACTIVATED
key_active = logic.KX_INPUT_ACTIVE
## Movement Keys ##
UPARROWKEY = logic.keyboard.events[events.UPARROWKEY]
DOWNARROWKEY = logic.keyboard.events[events.DOWNARROWKEY]
RIGHTARROWKEY = logic.keyboard.events[events.RIGHTARROWKEY]
LEFTARROWKEY = logic.keyboard.events[events.LEFTARROWKEY]
## Misc Keys ##
SPACEKEY = logic.keyboard.events[events.SPACEKEY]
### Double Tap to run ###
## 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
##Factors that will change speed##
SPEED = 1.25
if owner["Armed_Primary"] == False:
move *= 1.25
if owner["Wounded"] == True:
move *= 0.75
SPEED *= 0.75
AimingTarget = scene.objects['PlayerCam']
if AimingTarget["Aiming"] == True:
move *= 0.50
SPEED *= 0.50
if owner["RUN"] == True:
AimingTarget["Aiming"] == False
## Move ## (NAME, START, END, LAYER, PRIORITY, BLENDIN, PLAY, LYRWGHT, IPO_FLG, SPEED, BLEND)
BLENDTYPE = logic.KX_ACTION_BLEND_BLEND
PLAYTYPE = logic.KX_ACTION_MODE_PLAY
LYRWGHT = 0
IPO_FLG = 0
BLEND = 5
if UPARROWKEY == key_active:
if owner["RUN"] == True:
armature.playAction("PlayerRunning", 1, 9, 0, 0, 5, 1, 1, IPO_FLG, SPEED, 0)
move = -0.12
else:
armature.playAction("PlayerWalking", 1, 9, 0, 0, 5, 1, 1, IPO_FLG, SPEED, 0)
move = -0.08
if DOWNARROWKEY == key_active:
Striaght = 0.06
armature.playAction("PlayerWalking", 9, 1, 0, 0, 5, 1, 0, 0, SPEED, 0)
if Striaght > 0:
owner.applyMovement((0, Striaght, 0), True)
if LEFTARROWKEY == key_active:
Sideways = 0.08
armature.playAction("PlayerWalking", 11, 19, 0, 1, 5, 1, 0, 0, SPEED, 0)
if Sideways != 0:
owner.applyMovement((Sideways, 0, 0), True)
if RIGHTARROWKEY == key_active:
Sideways = -0.08
armature.playAction("PlayerWalking", 19, 11, 0, 1, 5, 1, 0, 0, SPEED, 0)
if Sideways != 0:
owner.applyMovement((Sideways, 0, 0), True)
## Reset Walk Cool Down ##
elif UPARROWKEY == key_none:
armature.playAction("PlayerWalking", 0, 0, 0, 2, BLEND, PLAYTYPE, LYRWGHT, IPO_FLG, SPEED, BLENDTYPE)
if owner["TAP"] == 2:
owner["TIMER"] -= 1
if owner["TIMER"] < -cool:
owner["TAP"] = 0
owner["TIMER"] = 0
owner["RUN"] = False
##Player does walking animation with arms if weapon if not armed##
if owner["Armed_Primary"] == False:
if UPARROWKEY or DOWNARROWKEY or LEFTARROWKEY or RIGHTARROWKEY == key_active:
armature.playAction("PlayerWalkingArms", 1, 9, 1, 1, 5, 0, 0, 0, SPEED, 0)
else:
armature.playAction("PlayerWalkingArms", 0, 0, 1, 1, 5, 0, 0, 0, 0, 0)
owner.applyMovement((0, move, 0), True)
<b>##Jumping##</b>
<b>if SPACEKEY == key_active:</b>
<b> Jump = 1</b>
<b>if Jump != 0:</b>
<b> armature.playAction("PlayerJump", 0, 10, 0, 0, 0, 0, 0, 0, SPEED, 0)</b>
<b> owner.applyMovement((0, 0, Jump), True)</b>
<b>if onwer["Armed_Primary"] == False:</b>
<b> armature.playAction("PlayerWalkingArms", 10, 20, 1, 1, 5, 0, 0, 0, SPEED, 0)</b>