Announcement

Collapse
No announcement yet.

How do you clamp InputAxis values before plugging them into Add Movement?

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

    How do you clamp InputAxis values before plugging them into Add Movement?

    If you have move forward mapped to W, and move right mapped to D, then pressing both W and D at the same time should move you diagonally twice as fast as moving just forward or to the right. How do you prevent this?

    #2
    Technically, you'd be moving about 1.41 times faster (square root of 2), but that would still be quite a bit faster.

    Since Add Movement takes a vector as input, I suppose you're passing values of +/- 1 for X and Y?
    A simple way to clamp the vector's norm to 1 would then be to normalize that vector (there's a node for that).
    I believe the normalize node is "safe" (it will never try to divide by zero if you have no input at all), so you should only have to add that single node.

    Comment


      #3
      Originally posted by JayRockets View Post
      If you have move forward mapped to W, and move right mapped to D, then pressing both W and D at the same time should move you diagonally twice as fast as moving just forward or to the right. How do you prevent this?
      AddMovementInput already normalizes, by the way.
      Marketplace Assets

      Advanced Mobile Input: Marketplace Page | Support Thread ――― Easy Input Remapping: Marketplace Page | Support Thread
      Multiplayer Blueprint Chat System: Marketplace Page | Support Thread ――― Closing Credits System: Marketplace Page | Support Thread
      Minesweeper Template: Marketplace Page | Support Thread ――― Maze Creator: Marketplace Page | Support Thread

      Comment


        #4
        So it's already done for me?

        Comment

        Working...
        X