How to change loop interval?

Hello,

I’m pretty new to UE5.1, so I apologize if I can’t understand complex methods anyone has, but I’ll try my best.

I have a first-person character that the player plays as and I’ve been wanting to add a bobbing-like effect to the camera to mimic walking. I’ve tried the ‘legacy camera shake’ BP, but it wasn’t what I was going for, and ended up making the shakes by hand with a camera animation sequence and using them in a camera shake base to play separately. The screenshot shows the functionality I want, however, the purpose of the delay is to control the time between ‘steps’ based on the player’s speed (walking slow increases the delay, and walking max speed means regular ‘step’ intervals for example).

The issue is looping this sequence. The screenshot below shows an earlier implementation that I tried. The problem with this is that the timer wouldn’t update when the player’s speed changed, using the last value it received as the time. Another odd thing with this is that there’s a long delay before the loop starts, so I’ve had to use the same flip-flop section before the timer so that there will be a step immediately when the player starts moving.

So my question is, how could I implement this? The first screenshot is probably the most simplified setup I thought of, but using delays in a timer doesn’t work, so I wouldn’t know how to loop this. The second method also works, but there’s no way to dynamically change the interval between steps with the timer.

Thanks in advance.

Easiest way is to retarget the third person project animations. Then use proper animations for moment.


you can use the cancel timer to reset the timer and re do it.

you can also add a negative value to the initial start delay so that it start way earlier if that can help.

Alright so, after spending an unhealthy amount of time in the blueprint editor, I was finally able to find the solution to this problem. For the record, I tried @Arodi007’s suggestion of clearing the handle, but couldn’t figure out how to make this work.

To clean things up first, I moved the blocks for the camera shake and audio to a separate function:

From there, I used a timeline with two event tracks for the left and right bobbing animations. I was able to then implement the ‘interval’ between steps by setting the second ‘step’ x amount of seconds after the first. I guess it’s important to note that 0.65-second intervals mimicked normal walking speed for me, so set what the base interval should be:

Then, I tie the left bob function to the corresponding pin out of the timeline for left and right. Now, when I start walking, it plays the timeline loop, calling the first function, and then the second one in a set interval, and stops when the player stops. Now, the saving grace that allowed me to dynamically change the ‘interval’ was using OnRep functionality. I don’t know what its intended purpose is, but you edit the variable you want and use RepNotify in the replication field. It then creates a function for the RepNotify, but I had to right click it and convert it to an event to be able to use it. Now, the OnRep event will update anytime that variable changes, which in my case is the players’ velocity. From there, you can use the ‘Set play rate’ function to change the rate at which the timeline loops, which finally lets me set the correct interval dynamically:


This entire section achieves what I was trying to get at without the drawback of using a timer and having an odd delay at the beginning; for context the blocks far from the main commented blocks were all previous attempts with the timers:

Thanks again for trying to help me out @Rev0verDrive @Arodi007

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.