Is it possible to get the location of the mouse for a player?
I want to make a unit follow the players mouse, when the left mouse button is pressed down.
I know of OneTwo's method of having invisible units, but I want to know if it's now possible to get the location of the mouse without some complicated workaround.
You are stuck using either using invisible units or mouse moved/clicked events, unless something changed with the last patch. Chances are this would be a little buggy with sudden mouse movements due to the lag on using mouse move events.
So you could use a click event to enable a mouse moved event which issued order to said unit to move to said location, a little delay would be involved, and sudden jerky mouse movement might not get picked up.
Is it possible to get the location of the mouse for a player?
I want to make a unit follow the players mouse, when the left mouse button is pressed down.
I know of OneTwo's method of having invisible units, but I want to know if it's now possible to get the location of the mouse without some complicated workaround.
Simply use the mouse moved event and save the current mouse position in a global varialble.
Like that you will always have access to the mouse position at all places within your code.
Only register for this event when you absolutely need it, as it will generate network traffic from all players for every mouse move they make. This event fires when a player moves themouse. Use "Mouse Moved UI Pos X" and "Mouse Moved UI Pos Y" to get the UI X,Y position where the player moved the mouse. Use "Mouse Moved World Pos X", "Mouse Moved World Pos Y", and "Mouse Moved World Pos Z" to get the X,Y,Z world position where the player moved the mouse.
Im not sure how much of an issue the network traffic really is, however the best way to avoid this would be to disable the trigger while its not needed and just turn it on while the mouse position needs to be tracked.
I would still prefer the native solution over a workaround by using hundreds of invisible units or something else.
u cant do that, the moment its enable the network traffic is horrendous. you have to turn it on and off at high speed like .1 seconds.
I dont think thats a very practical solution, since then the accuracy of the mouse position is dramatically lower than usually (Since it can just be measured 10x a second max, and only if the user moves at the right time).
It really depends on what the TC wants to achieve i guess. Id just disable the trigger as long as possible and turn it on for small time periods while its needed. By that, the generated network traffic is 0 while the trigger is inactive. Depending on how the TC wants to use it, the trigger might be disabled most of the time and just on for small time periods. If he needs to be able to get the mouse position at ANY TIME, he might try to go for the quick on-off approach if he doesnt need perfect accuracy.
ive made scripts for people doing diablo style movement were u hold click and it follows the mouse. at .1-.01 its very responsive and u make the trigger so it only generates 1 thread per .1-.01 seconds we even made it adjustable so players could turn up or down the sensitivity but i didnt notice any issues unless the sensitivity was above .8
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Is it possible to get the location of the mouse for a player?
I want to make a unit follow the players mouse, when the left mouse button is pressed down.
I know of OneTwo's method of having invisible units, but I want to know if it's now possible to get the location of the mouse without some complicated workaround.
@Demtrod: Go
You are stuck using either using invisible units or mouse moved/clicked events, unless something changed with the last patch. Chances are this would be a little buggy with sudden mouse movements due to the lag on using mouse move events.
So you could use a click event to enable a mouse moved event which issued order to said unit to move to said location, a little delay would be involved, and sudden jerky mouse movement might not get picked up.
When you begin to cast some spells like fungal growth for instance, it creates a splat actor that follows your mouse cursor until you select a target.
If you could find a way to track the position of a actor/model you might be able to use cursor splats to track the mouse cursor exactly.
Simply use the mouse moved event and save the current mouse position in a global varialble.
Like that you will always have access to the mouse position at all places within your code.
@Mille25: Go
mouse move is laggy, but u can compensate by turning the trigger off and on at fast speeds
How exactly is mouse moved laggy?
@Mille25: Go
Try using it in a public game (wont lag in local)
Blizzard definition:
Only register for this event when you absolutely need it, as it will generate network traffic from all players for every mouse move they make. This event fires when a player moves themouse. Use "Mouse Moved UI Pos X" and "Mouse Moved UI Pos Y" to get the UI X,Y position where the player moved the mouse. Use "Mouse Moved World Pos X", "Mouse Moved World Pos Y", and "Mouse Moved World Pos Z" to get the X,Y,Z world position where the player moved the mouse.
@SoulTaker916: Go
Im not sure how much of an issue the network traffic really is, however the best way to avoid this would be to disable the trigger while its not needed and just turn it on while the mouse position needs to be tracked.
I would still prefer the native solution over a workaround by using hundreds of invisible units or something else.
u cant do that, the moment its enable the network traffic is horrendous. you have to turn it on and off at high speed like .1 seconds.
I dont think thats a very practical solution, since then the accuracy of the mouse position is dramatically lower than usually (Since it can just be measured 10x a second max, and only if the user moves at the right time).
It really depends on what the TC wants to achieve i guess. Id just disable the trigger as long as possible and turn it on for small time periods while its needed. By that, the generated network traffic is 0 while the trigger is inactive. Depending on how the TC wants to use it, the trigger might be disabled most of the time and just on for small time periods. If he needs to be able to get the mouse position at ANY TIME, he might try to go for the quick on-off approach if he doesnt need perfect accuracy.
ive made scripts for people doing diablo style movement were u hold click and it follows the mouse. at .1-.01 its very responsive and u make the trigger so it only generates 1 thread per .1-.01 seconds we even made it adjustable so players could turn up or down the sensitivity but i didnt notice any issues unless the sensitivity was above .8