So I’ve been tampering with a script somebody created for my game. So I’ve added features like being wounded and walking slower while aiming in my game. The problem is that I’ve got the movement covered but I’ve been having troubles with the animations…
Here’s a script, I’ve bolded, italicized, and underlined the essential parts…
from bge import logic, events
scene = logic.getCurrentScene()
owner = logic.getCurrentController().owner
armature = 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]
### 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
## Move ## (NAME, START, END, LAYER, PRIORITY, BLENDIN, PLAY, LYRWGHT, IPO_FLG, SPEED, BLEND)
BLENDTYPE = logic.KX_ACTION_BLEND_BLEND
PLAYTYPE = logic.KX_ACTION_MODE_LOOP
LYRWGHT = 1
IPO_FLG = 0
<i><i><b>SPEED = 1</b></i></i>
BLEND = 5
<i><i><b>if UPARROWKEY == key_active:</b>
<b> if owner["RUN"] == True:</b>
<b> armature.playAction("PlayerRunning", 1, 9, 0, 0, BLEND, PLAYTYPE, LYRWGHT, IPO_FLG, SPEED, BLENDTYPE)</b>
<b> move = -0.12</b>
<b> else:</b>
<b> armature.playAction("PlayerWalking", 1, 9, 0, 0, BLEND, PLAYTYPE, LYRWGHT, IPO_FLG, SPEED, BLENDTYPE)</b>
<b> move = -0.08</b></i></i>
## Reset Walk Cool Down ##
elif UPARROWKEY == key_none:
armature.playAction("PlayerWalking", 0, 0, 0, 0, BLEND, logic.KX_ACTION_MODE_PLAY, 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
<i><i><b>##Factors that will change speed##</b>
<b>if owner["Armed_Primary"] == False:</b>
<b> move *= 1.25</b>
<b>if owner["Wounded"] == True:</b>
<b> move *= 0.75</b>
<b> SPEED *= 0.5</b>
</i></i>
AimingTarget = scene.objects['PlayerCam']
if AimingTarget["Aiming"] == True:
move *= 0.65
if owner["RUN"] == True:
AimingTarget["Aiming"] == False
owner.applyMovement((0, move, 0), True)