Description

There seems to be a discrepancy between the output of Get Mouse Position node depending on whether the node is inside an Actor function or called from Event Tick. If the node is present inside a function, then as soon as the mouse cursor leaves viewport/window area, the node returns 0, 0 vector. If the node is present in the event graph, not wrapped inside any function, then if the cursor leaves viewport, the node keeps reporting last known cursor position. 

Steps to Reproduce

(Project has been attached for easy replication & reproduction)

1. Open up Unreal Engine 4.21 and Create a blank project.

2. Create a Actor Blueprint named "Report Mouse XY"

3. Right click on the Event Graph-> Get Player Controller

4. Off of Get Player Controller -> Get Mouse Position.

5. Off of location X and Y, Make a Vector 2D.

6. Off of Make Vector 2D Return value, call function BuildString(Vector2d)

7. Off of Event Tick, Create a Sequence Node.

8. For Sequence 0, pull off a Print String Node.

9. Plug in the return value of Build string into the In String of Print String.

10. Create a custom Get Mouse Position Function (see GetMousePosition CustomFunction.png)

11. Call Get Mouse Position Custom Function.

12. Make a Vector 2D from Location X, and Y

13. Off of the Return value, use BuildString(vector2d)

14. Add another pin to sequence, and plug in Print String.

15. Compile & Save

16. Play In Editor, and move the mouse cursor across the viewport. Until it is off the viewport.

17. Observe the numbers of In Event Graph, and Inside of Function.

Result: Get Mouse Position node returns 0, 0 result as soon as the mouse cursor leaves viewport area if the Get Mouse Position node is contained within a blueprint function.

Expected: Get Mouse Position node should always return last known cursor position if the cursor exits the viewport, whether it is called from Tick, or from the Actor pure function.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-66596 in the post.

1
Login to Vote

By Design
ComponentUE - Gameplay
Affects Versions4.204.21
CreatedNov 15, 2018
ResolvedNov 19, 2018
UpdatedNov 26, 2018