x

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 get mouse position in screen space and not relative to widget?

I'm trying to get the mouse position in screen space and NOT in the relative space of the current widget and can't figure out how to do this.

For example:

  1. The node "GetViewportSize" returns the current resolution of the window the game runs in. This is exactly the space I need, (In my preview case: 1280 x 720)

  2. The nodes "GetMousePositionScaledbyDPI" and "GetMousePositiononViewport" return the mouse location in the relative space of the widget and so the top right corner of the screen equals X = 1920 and NOT 1280, which is the top right corner based on my current play window size.

Any suggestions how I can get the correct mouse position based on the current size of my play window?

Thanks and best regards, Daniel

Product Version: UE 4.18
Tags:
more ▼

asked Nov 24 '17 at 07:31 PM in Blueprint Scripting

avatar image

polygon
71 6 13 21

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

I would just get this really awesome plugin that adds a bunch of blueprint nodes including get mouse position on screen and get mouse position percentage on screen.

https://www.unrealengine.com/marketplace/item/f6637ea9663447e4b6a0578216992e70

more ▼

answered Nov 25 '17 at 04:54 AM

avatar image

Penton
6 1 6 5

(comments are locked)
10|2000 characters needed characters left

you can use bool APlayerController::GetMousePosition(float& LocationX, float& LocationY) const.

more ▼

answered Dec 16 '18 at 10:42 AM

avatar image

Haodong.Zheng
0

(comments are locked)
10|2000 characters needed characters left
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