Announcement

Collapse
No announcement yet.

How to make Character walk speed different on X axis and Y axis (top-down view)

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

    How to make Character walk speed different on X axis and Y axis (top-down view)

    Hello everyone, hoping you can help me with this little problem.
    I have a Character Blueprint, i already set WASD input in input settings, and this is the blueprint:

    What I'm trying to achieve:
    - Top-down camera
    - W and S moves player on X axis
    - A and D moves player on Y axis
    - X axis and Y axis movement must have different speeds, and I have to set them

    And the last point is the problem. I've created 2 float variables to handle X and Y speed (XSpeed and YSpeed variables) and attached them like in the image.
    The problem:
    - If I use only one variable (example, XSpeed), it gets applied to both X and Y movement
    - If I use both variables, they get ignored totally and speed have whatever default value Unreal sets.

    I think the problem lies in the "Set max walk speed" block, but I can't understand/didn't find what other block to use, or how to handle this logic.
    Doesn't help that I'm a total noob.

    Could you help me with this? I know I'm missing something completely stupid.

    #2
    It's because InputAxis works as EventTick, you should create one ActionMapping for W/S, and one for A/D, and have those events change Max Walk Speed on Pressed.

    Comment


      #3
      Where it says axis value on the event, try multiplying the green line coming off of it by a number like 0.5 before plugging the result of that into the movement node.
      My Game Frontier Devblog HERE

      Comment


        #4
        Originally posted by Orkney View Post
        Where it says axis value on the event, try multiplying the green line coming off of it by a number like 0.5 before plugging the result of that into the movement node.
        I didn't try it but I like this idea, could be difficult to give it a precise value but it's a wonderful "Plan B" approach. I didn't think of that.

        Originally posted by GunsLingerSRB View Post
        It's because InputAxis works as EventTick, you should create one ActionMapping for W/S, and one for A/D, and have those events change Max Walk Speed on Pressed.
        First of all, thanks for your.... input.
        Yeah, I'm sorry, I love bad puns.

        I tried this, like you can see in the image below this post, but i think i'm again missing something, because the character moves only 1 pixel per button press (even by holding the button).
        I think it's the Scale Value giving me problems, but at the moment I wouldn't know how to connect this in a different way.

        Comment


          #5
          Sorry for late reply.
          You should only put Max Walk Speed node on ActionInput.
          Leave AddMovementInput node as it was before, on AxisInput.

          Comment

          Working...
          X