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?

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.

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

I found this thread that may help

Well this is frustrating, since the thread says that this is exactly what they are looking for, but the video is down! :mad:

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!

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

Checking Triggered once :

Checking each tick:

5 Likes

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

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.

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

I know this is old but it may help me right now. What does the Get right vector and Last Frame Forward vector plug into before setting the direction variable in the second example?

Thanks!

2 Likes

dot product

2 Likes