Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to delay mouse input?

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.

Any ideas?

Product Version: UE 4.11
more ▼

asked May 10 '16 at 10:15 AM in Blueprint Scripting

avatar image

Michael Asquith
185 8 13 20

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

more ▼

answered May 10 '16 at 04:21 PM

avatar image

1.2k 58 12 62

avatar image RVillani May 10 '16 at 08:50 PM

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.

avatar image Michael Asquith May 10 '16 at 11:05 PM

Thanks Est_Engine, you Sir, are a gentleman and a scholar! Here is my solution: alt text

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.

mouse delay.jpg (128.0 kB)
avatar image kyunkyun Blast Jul 28 '16 at 06:10 AM

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.

avatar image Michael Asquith Jul 28 '16 at 06:38 AM

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!

avatar image kyunkyun Blast Jul 28 '16 at 03:58 PM

It work! Thanks your your guidance mate. alt text 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? alt text

untitled.png (127.8 kB)
untitled2.png (20.6 kB)
avatar image Michael Asquith Jul 29 '16 at 12:05 AM

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.

avatar image kyunkyun Blast Jul 29 '16 at 06:54 AM

Thanks for your explanation Michael, it's really helpful. Have a good day.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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?

more ▼

answered May 10 '16 at 05:58 PM

avatar image

94 8 7 12

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question