Announcement

Collapse
No announcement yet.

Translating velocity to local directions?

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

    Translating velocity to local directions?

    Hi! I'm trying to set up some strafing animations and tried to use the character's Y velocity to determine whether or not he is moving left or right.
    But I found that velocity is world aligned, not local. So if my character faces south instead of north, the strafe direction is inverted.

    Can I translate this to local space in my event graph by using something like the controller's rotation somehow?

    #2
    There are a few nodes that may help, but a velocity is generally non directional, so I'm a bit confused as to what you are using.

    Comment


      #3
      I'm basically trying to find a value I can use to see if my character is strafing left or right. I tried using the velocity Y axis, but it appears to be world space, rather than local.

      Comment


        #4
        If you use the Get Velocity node on the actor you should get a world aligned vector that describes your speeds.

        The sum of the 2 (x and y) would be your total speed in that forward direction I believe.

        which would or should not exceed the maximum set in the movement component.

        you can use the value of X (positive or negative) to determine your heading, coupled to the value of the forward vector.

        Comment


          #5
          I got something going, but I'm not getting the range of values I'm expecting, and I need some help re-adjusting them.

          My character has a directional velocity of -300 to 300. This means that at 0, it's moving straight forward, at 150 it's moving diagonally, and 300 it's moving right.

          I managed to replicate this by using a rotatevector node.
          Click image for larger version  Name:	20200216-20_32_51BP_AnimChar.jpg Views:	0 Size:	142.2 KB ID:	1721956

          It works perfectly for 0, 300 and -300, but when give my character input to move diagonally, I get a value of 212/-212 instead of 150.
          So the blending of my animation doesn't match the direction my character is actually moving, making it slightly skate across the ground.
          How would I adjust this?


          Edit: Figured it out! My blendspace was set up as my character movement was handled by a Speed * 360 degree Orientation setup.
          Turns out my setup is 2 axis based instead. (X is forwards and backwards, while Y is left and right.)

          I just had to set up my blend space accordingly. (So left and right is literally on the left and right of the blend space and not in the corners).
          Last edited by Graylord; 02-16-2020, 05:11 PM.

          Comment


            #6
            Also - There are built-in functions on FTransform to transform positions and directions to local space.
            https://www.casualdistractiongames.com

            Comment

            Working...
            X