I’ve got an edge scrolling function for an RTS-style camera pawn that works perfectly, but its on tick. I only want to fire the nodes when the mouse enters a certain border along the edge of the screen if possible, to minimize the number of tick events. I’m thinking I could do this with invisible Widgets stretching along the screen borders and use an event dispatcher for when the cursor overlaps one or two (corners) of the four widgets (one for each screen edge). That seems like a brute force, heavy-handed method. Is there any built-in functionality for when the mouse cursor enters user-defined zones of the screen in blueprints? I see “Bind Event to On Begin Cursor Over”, which gave me the widget idea. Any other ideas how one might go about doing this? Maybe with a completely different methodology?
Wow, thanks for the fast reply! I’ll do some research into that, any suggestion on topics to google in addition to “trigger blocks”? Thanks for the help!
Thank you for the video, I have seen this one in particular. The technique this author uses, as well as most other videos I’ve seen explaining edge scrolling, rely on an event tick to check the mouse position constantly. This is currently the same as the functionality I’ve employed in the screenshot in my original post. I’m looking for a method to get away from an on-tick style that is constantly firing, even when my mouse cursor is no where near the screen edges, to a method where the on-tick only begins once the mouse has entered the defined border space (I’ll use a timer by function name to emulate the tick event after an event node is activated by the mouse entering the border space). I’m thinking four event dispatchers, each with a timer and function, but I’m not sure what to use, that isn’t tick-dependent, to fire off that initial activation of the event dispatchers. It would be similar to firing off the on component begin overlap event node, except instead of two collision volumes overlapping it would be the mouse cursor overlapping a 2D section of the viewport.
So I figured out a solution using the method I described earlier, though slightly different. I created one widget instead of four. The widget contains a canvas panel, two vertical boxes and two horizontal boxes.
Using the Canvas’ Anchors to keep the boxes along the edges, I then added two event dispatcher to the widget, and called them (start and stop edge scrolling) by using Event On Mouse Enter and Event on Mouse Leave respectively.
With that the widget was done, aside from some other blueprint nodes to ensure the thickness and positions of the boxes were as desired. I then bound the two event dispatchers on my blueprint with the edge scrolling logic (in this case my RTS camera). The binding occurs on Event Begin Play. I created a start and stop function for the two bindings.
The start function initiates a timer that runs on World Delta Seconds so it fires on tick, but only while the mouse remains within the desired border area of the screen.
I’m experiencing some screen stuttering despite FPS being better (insignificantly if I’m honest) with my event dispatcher method of edge scrolling. I found the Set Actor Tick Enabled node (thanks to one of Everynone’s posts from 7 years ago), and I’m using that with Event Begin to turn ticks off for my camera actor, then when the event dispatchers are called, all they do is turn ticks on and off for my camera actor. I leave my nodes from the screenshot in my first post alone to do their thing. This seems to give me the best of both worlds: getting away from constant event ticks and not suffering from the screen stutter I got with the event dispatchers.
Note: this has the draw back of affecting all code that relies on Event Tick for this one actor.