Announcement

Collapse
No announcement yet.

How to split functions of one Button?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to split functions of one Button?

    Hello, and Thank you so much for taking the time to help me out!

    I'm new to unreal, but I've been flailing about the Blueprint System for a few days now..

    I'm working on a Side Scroller (not a Sprite based one but a 3D side scroller) and I wanted to have a controller button (X) function as the run mechanic. Pretty basic stuff- or so I thought...

    So I got the idle and walk animations and their respective blueprints for left and right movement and I thought I was doing pretty decent... Until I decided to build a blueprint for the Run mechanic...

    My goal was to have my character walk in a direction until the (X) button is pressed and held-then while holding the (X) button the characters animation would change from walk to a run? Seems simple enough..

    The problem I run into is that the (X) button can't share a function with Run left and Run Right.. When pressing the joystick in one direction and pressing the run button (X) it causes both animations to "fight" over themselves...I have tried to find the right blueprint node to break up the "Gamepad Face Button Left"'s press/release function but even after several different types of nodes trying to blunder apon the right one.. I am still no closer to my goal..

    I have tried so many things... It took me forever to even triangulate the problem. So essentially I would love someone's wisdom and divine insight onto how to set this basic feature up?

    I assumed it would be pretty intuitive seeing as it's something abundantly seen in almost every Unreal side scroller and I desperately could use any/all aid that can be given!

    Thanks again for taking the time to help out a lost fool like my self!

    Cheers.

    #2
    Hi Coyote King.

    To synopsise it sounds like you have two events, one for running left and running right and they cannot, obviously, execute at the same time or be mapped to the same input. Might I suggest that you need some decision logic around the player orientation state? It sounds like you actually need just one event (Run), which will read the current state of the player's orientation and then play the animation for running in the appropriate direction.

    Comment


      #3
      Wow.. Okay, thank you for the response!

      Any rough idea on how one would go about setting a players orientation state? Or create some kind of decision logic?

      Thank you! And I apologize for being such a laymen in regards to this... Everything seemed like it was making sense until this issue regard its obstinate head..

      Thank you again for taking the time to respond.

      Cheers.

      Comment


        #4
        You must already have some concept of orientation state if you're able to go left and right and update the character. When the character moves positive x for a frame you've effectively moved right, -ve: left. If you were to make this information available to the play run animation logic, then the logic would essentially say "X button pressed! if we're currently moving right, play the right run animation, otherwise the left animation". I presume you're doing blueprints so to form a decision, you'd need something like a branch operation. You can get a branch box up in your blueprint by right clicking the background and typing "if". If you have a simple boolean representing your current direction, you:
        1) create the branch ("if")
        2) drag the boolean onto your blueprint
        3) select get from the context menu
        4) from the little roundtangle now created, click the node on the right and drag out a line to the branch's "condition" input
        4) drag from the "true" "false" execution arrows you see on the right of the "branch" box to do whatever you do to play your animations.

        On the very simplest level, if your character has no concept of speed or momentum and simply walks/runs at static defined speeds, you could store a left/right boolean when you press the d-pad left/right. It might not do for a finished game, but it might give you what you need to get up and running.

        Comment

        Working...
        X