Page 1 of 2 12 LastLast
Results 1 to 20 of 34
  1. #1
    Member
    Join Date
    Oct 2014
    Location
    Long Beach, Ca
    Posts
    152

    Double Tap to Run/Sprint

    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?
    Last edited by MarcoYolo; 17-Sep-17 at 09:25.



  2. #2
    Member BluePrintRandom's Avatar
    Join Date
    Jul 2008
    Location
    NoCal Usa
    Posts
    18,329
    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
    Break it and remake it - Wrectified
    If you cut off a head, the hydra grows back two.
    "headless upbge"



  3. #3
    Member
    Join Date
    Oct 2014
    Location
    Long Beach, Ca
    Posts
    152
    Originally Posted by BluePrintRandom View Post
    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.



  4. #4
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,166
    with a property
    double w is running.blend


    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.
    Last edited by Cotaks; 13-Sep-17 at 18:17.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  5. #5
    Member
    Join Date
    Oct 2014
    Location
    Long Beach, Ca
    Posts
    152
    Originally Posted by Cotaks View Post
    with a property
    double w is running.blend


    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?



  6. #6
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,166
    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.
    Last edited by Cotaks; 13-Sep-17 at 22:56.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  7. #7
    to me this seems like a clumsy mechanic. i prefer a toggle to walk/run.

    anyway:
    doubletap.blend

    EDIT:
    it should be easy to tag an animation to the "RUN" property when the the W key is pressed.
    Last edited by Daedalus_MDW; 14-Sep-17 at 03:10.
    System "IVAN" (rev 1.3b) - Win7 64bit - Blender 2.74:
    CPU- Intel i3-3220 3.30 Ghz | GPU- EVGA GTX 970 | RAM- GSkill Ares 16GB 1600 Mhz | MB- ASUS P8Z77-V LK



  8. #8
    Member
    Join Date
    Oct 2014
    Location
    Long Beach, Ca
    Posts
    152
    Originally Posted by Daedalus_MDW View Post
    to me this seems like a clumsy mechanic. i prefer a toggle to walk/run.

    anyway:
    doubletap.blend

    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?
    Last edited by MarcoYolo; 14-Sep-17 at 17:15.



  9. #9
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,166
    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
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  10. #10
    Originally Posted by Cotaks View Post
    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.
    System "IVAN" (rev 1.3b) - Win7 64bit - Blender 2.74:
    CPU- Intel i3-3220 3.30 Ghz | GPU- EVGA GTX 970 | RAM- GSkill Ares 16GB 1600 Mhz | MB- ASUS P8Z77-V LK



  11. #11
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,166
    Originally Posted by Daedalus_MDW View Post
    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.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  12. #12
    Member
    Join Date
    Oct 2014
    Location
    Long Beach, Ca
    Posts
    152
    So, back on track. How do I make the animation play within the script?



  13. #13
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,166
    Originally Posted by MarcoYolo View Post
    How do I apply a walking animation(for a rig) in the script?
    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.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  14. #14
    Member
    Join Date
    Oct 2014
    Location
    Long Beach, Ca
    Posts
    152
    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)



  15. #15
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,166
    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.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  16. #16
    Member
    Join Date
    Oct 2014
    Location
    Long Beach, Ca
    Posts
    152
    Originally Posted by Cotaks View Post
    you use owner so change own to owner
    Are you talking about the one on the armature? I changed that one and still nothing.



  17. #17
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,166
    Originally Posted by MarcoYolo View Post
    Are you talking about the one on the armature? I changed that one and still nothing.
    please open console and check errors.

    yes i was talking about changing:
    own.scene.objects
    into
    owner.scene.objects
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  18. #18
    Member
    Join Date
    Oct 2014
    Location
    Long Beach, Ca
    Posts
    152
    Originally Posted by Cotaks View Post
    please open console and check errors.

    yes i was talking about changing:
    own.scene.objects
    into
    owner.scene.objects
    Alright, that's what I did. Same result...



  19. #19
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,166
    Originally Posted by MarcoYolo View Post
    Alright, that's what I did. Same result...
    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
    Last edited by Cotaks; 14-Sep-17 at 18:45.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  20. #20
    Member
    Join Date
    Oct 2014
    Location
    Long Beach, Ca
    Posts
    152
    So this came up...
    Attached Images Attached Images



Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •