Convert Mouse Location To World Space doesn't work?

For turn based game I need to measure distance between a character and mouse cursor in real time. To make thise I use EventTick and ConvertMouseLocationToWorldSpace. But it doesnt work properly because this funktion take a coordinates of the centre of screen instead of a mouse cursor coordinates! So, if I move mouse - the coordinates dont varia, but if i move a camera - then the funktion measure distance between a character and the new center of the screen.
The qwestion is: how to measure the distance between a character and mouse cursor in real time?
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“thumb”,“data-tempid”:“temp_197723_1594723554753_66”}[/ATTACH]

Did you make the mouse visible?

The *Convert Mouse Location To World *node works pretty well but there’s no need to get it involved here, try this:

As a bonus, if you opt for *Get Hit Result Under Cursor for Objects *instead, you can start filtering collision right there for more control over what you’re measuring against.

measure.gif

2 Likes

Thanks a lot for the answer.
But I have more question. I need use the distance measuring only in combat and translate that distance into Action Points, and then put it into software cursor widget. I try do it, and Action Points calculete correct, but cursor widget spawn on the centre of the screen and cursor dont chenge.
How it should to do correct?

Try it like this:

Aps.gif
https://forums.unrealengine.com/core/image/gif;base64

And in the widget:

Aps.gif

09f26345a5b559e73ba2922c25ed8ad6d58f1087.gif

I did so, but did not create a Custom Event Update Cursor Data - Aren’t the variable dont update in widget without Custom Event?


Now it works, but only while the cursor moves. When the cursor stops, it disappears. Why is this happening?

This is inefficient, why cast every frame? Push the data into the widget directly. It will work, of course, it’s just not recommended.

Most likely because you’ve assigned a widget in the Project Settings. Either do it there or do it manually as suggested above. Not both. For example, whenever the cursor turns into CardinalCross, it will spawn the assigned widget and override the one you created.