Jump to content
Sign in to follow this  
Scrocco88

Get pointed location

Recommended Posts

How can i get the location pointed by a player?

Something like the ( ) cursor when using support modules.

Tried with cursorTarget but it works only if targeting some object, not working if pointing at ground.

Thanks

Edited by Scrocco88

Share this post


Link to post
Share on other sites

Thank you, it worked.

PS. I've been playing on your wasteland servers these days.... i really love your work! :D

Share this post


Link to post
Share on other sites

im using this to get the pointer position:

(findDisplay 46) displayAddEventHandler ["MouseMoving","cursorPos=screenToWorld [_this select 1, _this select 2];hint format ['%1',cursorPos];"];  

but it seems working only after a first Restart of my mission.

What am i doing wrong? Do i need to waitUntil some library before using it?

Edit:

Actually it works only with a very short distance... if i try to look at something distant a get coordinates much more far away then the real point :(

Edited by Scrocco88

Share this post


Link to post
Share on other sites

it's starting too soon is all.

waitUntil {!isNull(findDisplay 46)}; 
(findDisplay 46) displayAddEventHandler ["MouseMoving","cursorPos=screenToWorld [_this select 1, _this select 2];hint format ['%1',cursorPos];"];

---------- Post added at 10:55 PM ---------- Previous post was at 10:45 PM ----------

it's starting too soon is all.

waitUntil {!isNull(findDisplay 46)}; 
(findDisplay 46) displayAddEventHandler ["MouseMoving","cursorPos=screenToWorld [_this select 1, _this select 2];hint format ['%1',cursorPos];"];

the distance problem is probably because it doesn't see obstructions so anything above ground level goes to the max distance.

Share this post


Link to post
Share on other sites

The point returned is always the same point, in the upper-left part of the screen.

And it's exactly the (0,0) point of the GUI EDITOR grid.

Share this post


Link to post
Share on other sites

Is this what your after

while {true} do { 
 _pos  = screenToWorld [0.5,0.5]; 
  if (!isnull cursortarget) then { _pos = getpos cursortarget };
      sleep 0.1;
       hint format ["%1",_pos];
    };

[0.5,0.5]; is the center of the screen

I use cursortarget to find buildings other wise it looks through them

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×