So I have my pawn pitch and yaw responding perfectly to my mouse input - however what I want, what I really really want, is to add an intentional delay between the mouse X/Y axis and the pawn moving. I know that seems like something you would not want to do, however I do need it.
I’ve messed around with delays and timers in every way conceivable but they wont work as the input from the mouse is constant like a tick so delays just cause stuttering, obviously. I need some way of recording the last few frames of input and then applying it after a time has passed.
Hi man , its not the best way to do it but here an example.
Make a float array. set it to 100 , or use the begin_play event to set it properly.
The lenght of the array is directly connected to the time you want to delay.
Now Get the mouse event and use a loop to : Move of 1 place every value stored inside.
Set the 100°(the last) as the 99, then the 99 as the 98… and in the 0 put the current mouse value.
This will store all the amaunt of the mouse for some time.
To use it you simply use the array100(the last) , instead of the current mouseX.
Depending on the framerate you will have variation in the time delay.
Could you not just use a “disable input” or you need the player to be able to continue to move and just not have control of mouse inputs?
Great solution. To avoid a huge array you could record frames only every 0.1 seconds, for example, and then, when playing them back, interpolate between them. For this you would record not just the delta, but also the time it was recorded, for each index. An array of a custom struct would be ideal.
Thanks Est_Engine, you Sir, are a gentleman and a scholar! Here is my solution:
I made the incoming mouse frames insert at index 0, and remove the frame above the delay to avoid the array being longer than necessary. Then I get the frame that corresponds to the required delay. Works perfectly.
Hiya. I can’t upload the blueprint sorry, it’s part of a project I cannot share. The nodes above are the only nodes you need to make it work. Make sure the “FrameDelay” Int variable has a default number set that is higher than 0 (ie. 10). Then use a tick event to drive whatever from the “DelayedPitch” variable. Any more questions just ask!
Hi Michael, could you upload your blueprint example for adding delay to mouse input? I’m trying to emulate mouse delay by following your solution but it didn’t work.
It work! Thanks your your guidance mate.
From what I understand the the default value for “Frame Delay” representing how much delay we want to add isn’t it? So for example what is the value for “Frame Delay” if I want to add delay for 1 second?
It’s delaying by frames so if you game is running at 60fps a value of 60 should make the delay 1 second. However that would be frame rate dependent. If your frame rate dropped to 30fps for some reason then the delay would increase to 2 seconds. I’m sure there is a way to add delta time into the mix and set the delay as a “time” (ie. 1.5 seconds) that never changes with the frame rate - however for my needs a simple 10 frame delay is all I needed.
Thanks for your explanation Michael, it’s really helpful. Have a good day.