MarcoYolo
(MarcoYolo)
September 13, 2017, 1:31pm
1
So I’ve been trying to make an animation walking speed for my game but failed, like usual…
Before you ask, yes. I’ve watched the Tim3ster’s tutorial.
What am I trying to accomplish? So in some PC games, I’ve played. I realize when you press the up arrow, you’re walking. But when you press up arrow simultaneously, the player moves faster. How do I accomplish this?
press up------------and-------movement(in hitbox)walk
not press shift–/___-------animation(in armature)walk
press up-----------and---------movement(in hitbox) run
press shift-------/___-------animation(in armature) run
in logic bricks
MarcoYolo
(MarcoYolo)
September 13, 2017, 1:47pm
3
BluePrintRandom:
press up------------and-------movement(in hitbox)walk
not press shift–/___-------animation(in armature)walk
press up-----------and---------movement(in hitbox) run
press shift-------/___-------animation(in armature) run
in logic bricks
I was trying to make it so you walk normally but a bit slow when you press up. When you start constantly hitting the up button, the player walks faster and starts to jog. I was wondering how to do that.
I see what you’re going for but not what I wanted.
Cotaks
(- Click for (UP)Bge resources)
September 13, 2017, 4:13pm
4
with a property
double w is running.blend (456 KB)
or you can use states or python, above example is pure bricks using 1 property.
expand it to add as much steps as you like.
MarcoYolo
(MarcoYolo)
September 13, 2017, 5:02pm
5
Cotaks:
with a property
[ATTACH]498208[/ATTACH]
or you can use states or python, above example is pure bricks using 1 property.
expand it to add as much steps as you like.
Thanks, this seems useful. The only problem is that it’s a bit cluttered and unorganized. Is there a python script perhaps?
Cotaks
(- Click for (UP)Bge resources)
September 13, 2017, 8:40pm
6
Is there a python script perhaps
Nah sorry, this is all you get
you can remove the double sensor and connect the one left with the and of the one you removed
1x property 2x and 1x motion is needed for each step, remove the double as said above then just copy that setup.
to me this seems like a clumsy mechanic. i prefer a toggle to walk/run.
anyway:
doubletap.blend (1.14 MB)
EDIT:
it should be easy to tag an animation to the “RUN” property when the the W key is pressed.
MarcoYolo
(MarcoYolo)
September 14, 2017, 11:39am
8
Daedalus_MDW:
to me this seems like a clumsy mechanic. i prefer a toggle to walk/run.
anyway:
[ATTACH]498224[/ATTACH]
EDIT:
it should be easy to tag an animation to the “RUN” property when the W key is pressed.
How do I apply a walking animation(for a rig) in the script?
Cotaks
(- Click for (UP)Bge resources)
September 14, 2017, 3:01pm
9
to me this seems like a clumsy mechanic. i prefer a toggle to walk/run.
explain clumsy? the double brick in there? removed it. and if you mean bricks in general are clumsy, thats true i dont like bricks either, i just made it with bricks because TS and 90% of the people here don’t even know python.
my one property is acting as state, you can set it to walk instead of 1, set to jog instead of 2, set to run instead of 3, etc
Cotaks:
explain clumsy? the double brick in there? removed it. and if you mean bricks in general are clumsy, thats true i dont like bricks either, i just made it with bricks because TS and 90% of the people here don’t even know python.
my one property is acting as state, you can set it to walk instead of 1, set to jog instead of 2, set to run instead of 3, etc
MECHANIC, not method. having to double tap to run as an action to perform when PLAYING the game.
im my OPINION, i dont like it.
nothing of what i said had any implication of logic bricks, or that i was even talking to you, Cotaks. sorry for any misunderstanding.
Cotaks
(- Click for (UP)Bge resources)
September 14, 2017, 3:37pm
11
Daedalus_MDW:
MECHANIC, not method. having to double tap to run as an action to perform when PLAYING the game.
im my OPINION, i dont like it.
nothing of what i said had any implication of logic bricks, or that i was even talking to you, Cotaks. sorry for any misunderstanding.
Ah ok, sorry and np, i indeed thought it was meant for me.
MarcoYolo
(MarcoYolo)
September 14, 2017, 3:44pm
12
So, back on track. How do I make the animation play within the script?
Cotaks
(- Click for (UP)Bge resources)
September 14, 2017, 3:44pm
13
you need to add:
armature = own.scene.objects[‘your armature’]
armature.playAction(“animation”, “start frame”, “endframe”)
at the places where he walks and or runs, or write a few lines more to seperate it from each other, and i would put it into functions instead of using it in the script way.
MarcoYolo
(MarcoYolo)
September 14, 2017, 3:52pm
14
So far it hasn’t worked.
Note: I’ve successfully edited the script so it uses the up arrow and not the w key.
Here’s the script. I’m not too sure what’s wrong it.
from bge import logic, events
owner = logic.getCurrentController().owner
scene = bge.logic.getCurrentScene()
armature = own.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)
Cotaks
(- Click for (UP)Bge resources)
September 14, 2017, 3:53pm
15
owner = logic.getCurrentController().owner
scene = bge.logic.getCurrentScene()
armature = own.scene.objects[‘PlayerRig’]
you use owner so change own to owner
and if you added scene for the line i gave you, you dont need it.
own or owner in this case can define the scene where it is at.
so own.scene grabs the scene where the object is located.
MarcoYolo
(MarcoYolo)
September 14, 2017, 3:55pm
16
Are you talking about the one on the armature? I changed that one and still nothing.
Cotaks
(- Click for (UP)Bge resources)
September 14, 2017, 3:59pm
17
please open console and check errors.
yes i was talking about changing:
own.scene.objects
into
owner.scene.objects
MarcoYolo
(MarcoYolo)
September 14, 2017, 4:08pm
18
Alright, that’s what I did. Same result…
Cotaks
(- Click for (UP)Bge resources)
September 14, 2017, 4:36pm
19
oke and what errors popped up in the console?
tested the play action works here so something else is wrong try adding the other command like the eaxample below, maybe it needs to define the layer and others as well. but first check you console on errors.
# name, start, end, layer, priority, blendin, mode
armature.playAction('aiming_with_'+own['carry_weapon'], 0, 30, 0, 2, 0, 0)
#just my test example