Announcement

Collapse
No announcement yet.

Detect when a character is turning left or right?

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

    Detect when a character is turning left or right?

    Hello, everyone!

    Realistically, when a person is running, they lean into a turn. I want to replicate this in Unreal 4, but first I need to know how to detect when an actor is leaning.

    What I theorized was to simply check every .1 seconds (or another variable of a second) and see if the rotation value has changed. If it's positive, lean to the right, and vice verse for negative. Problem is, is that this only works in absolutes. It would only detect that you are turning left or not, and not how hard you are turning left.

    And since this character is AI driven, I can't simply grab information from inputs.

    Is there another way of doing it? Or should I stick to what I have now?
    Check out our game Arcus!

    #2
    I remember a commentary node in Left 4 Dead that talked about this, I don't remember if they gave any details into how they did this.
    I will try to get around to doing the commentary again and see what it says.



    Originally posted by StevenWaltherMedia View Post
    What I theorized was to simply check every .1 seconds (or another variable of a second) and see if the rotation value has changed. If it's positive, lean to the right, and vice verse for negative. Problem is, is that this only works in absolutes. It would only detect that you are turning left or not, and not how hard you are turning left.
    Could you compare the difference between the rotations and use that as a multiplier that you then feed into the anim system ?
    An alternative is to accumulate the players rotation delta for N seconds in the Controller and use that.

    HTH
    Never say Never, Because Never comes too soon. - ryan20fun

    Frames Per Second is NOT a proper performance metric, You should use frame time. You can read this or this as to why.
    (Profiling) Tools: RenderDoc (UE4 Plugin), NVIDIA nSight, AMD GPU PerfStudio, CodeXL
    Good articles/Series: A trip through the Graphics Pipeline 2011

    Comment


      #3
      I found this thread that may help
      Never say Never, Because Never comes too soon. - ryan20fun

      Frames Per Second is NOT a proper performance metric, You should use frame time. You can read this or this as to why.
      (Profiling) Tools: RenderDoc (UE4 Plugin), NVIDIA nSight, AMD GPU PerfStudio, CodeXL
      Good articles/Series: A trip through the Graphics Pipeline 2011

      Comment


        #4
        Well this is frustrating, since the thread says that this is exactly what they are looking for, but the video is down!
        Check out our game Arcus!

        Comment


          #5
          I can try expanding on my system that I have already. I would have to have it check every tick, but running code on tick where different fps would result in different results is very sloppy. I'll try what you suggested, though!
          Check out our game Arcus!

          Comment


            #6
            I you want to check turning based on rotation , here is is 2 Solutions :

            Checking Triggered once :
            Click image for larger version

Name:	109.PNG
Views:	1
Size:	269.8 KB
ID:	1098632

            Checking each tick:
            Click image for larger version

Name:	110.PNG
Views:	1
Size:	269.4 KB
ID:	1098633
            Website [ LINK ]
            Twitter [ LINK ]
            Support ! [ LINK ]

            Comment


              #7
              This is similar to what I had, except just done better because it seems like you know what you are doing

              I guess what is next is getting the result as a float and turning that into how fast you are turning which would become how far the lean is.
              Check out our game Arcus!

              Comment


                #8
                The direction is a value between -1.0f and 1.0f , so if you want to get delta angle(how fast) , then DeltaAngle = Direction * 90.0f

                if you use Tick that means DeltaAngle per DeltaTime
                if you are using the timer , DeltaAngle per Time
                Website [ LINK ]
                Twitter [ LINK ]
                Support ! [ LINK ]

                Comment

                Working...
                X