Haven't actually done this, but it seems like something like this should work:
Event - mouse clicked (or moved)
Actions - order unit to move targeting (here you'd call the world (not UI) mouse position x and y converted to a Point)
if you just want mouse movement use something like this:
MousetrackingEventsUI-PlayerAnyPlayermovesmouse.LocalVariablespoint=(Point((MouseXpositionintheworld),(MouseYpositionintheworld),(MouseZpositionintheworld)))<Point>ConditionsActionsUnit-Order(Unit1fromunitgroup[(Triggeringplayer)]) to ( Move targeting point) (Replace Existing Orders)
the last one is just an "Issue Order" with an "Order targeting Point"
(the unit group part is from what i used in my code, replace this to your own needs)
if you want to have like a rightclick hold movement style (i dont know exactly how diablo moves) you need 2 aditional trigger (you can put it in 1 but i prefer to split it up, as then you can turn off the mouse movement tracking trigger off by default to save resources)
This will run when you click the right mouse button, it will then activate moustracking in the other trigger and your unit will start following your mouse as long as you keep it pressed down.
If you let the right mouse button go it will activate the trigger below, turning tracking off.
The above solution doesn't scale to multiple players, not does it answer your facing question, so I'll comment on those.
I do some similar things in my game. I store information about my 5 players in an array. Player 0 is bugged, and seems to always have vision of the entire map, so my players are #1-5 in the map settings.I have an array of size 6 (ie has slots 0-5).
Make a data type 'record' to store information about your players. You'll want to have the fields:
Unit-hero_// The players character/hero/unit/whateverBoolean-right_mouse_down_=False// track the mouse state
Make an array of appropriate size for your number of players (and i assume your player numbers are continous from 1.) The array should be of the record type you've made. Let's call the array 'players'
Now make a trigger similar to what the previous poster suggested:
Make a similar trigger RightClickOff that handles the mouse up state, and sets the variable
to false. Now make a trigger to handle the right actions on mouse movement (and forgive my pseudo code,
I don't have the editor available)
MouseMovedMouseMovedEventsUI-PlayerAnyPlayermovesmouse.LocalVariablespointtarget=PointFromXY(MouseXpositionintheworld,MouseYpositionintheworld)ConditionsActionsIfthenelseif(conditions)=>players[TriggeringPlayer()].right_click_on_==Truethen=>// Move the unitUnit-IssueOrderTargettingPoint-Orderunitplayers[TriggeringPlayer()].hero_toMovetargettingpointtargetelse=>// Just adjust the facing// I am making this command up! I am sure there's one like it thoughUnit-Orderunittofacepoint-Orderunitplayers[TriggeringPlayer()].hero_tofacepointtarget
If there isn't an action for making a unit face a point, but rather only one facing an angle,
you'd just need to compute the angle between the position of players[i].hero_ and target.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
How do you order a unit to follow owner's mouse AUTOMATICALLY (as in Diablo)? Also, how would you make unit face direction of owner's mouse?
I thought I could figure these out since Patch 1.2 added Mouse Moved trigger event but I am stuck and have no idea what to do...help!
Haven't actually done this, but it seems like something like this should work:
Event - mouse clicked (or moved) Actions - order unit to move targeting (here you'd call the world (not UI) mouse position x and y converted to a Point)
@dgh64: Go
if you just want mouse movement use something like this:
the last one is just an "Issue Order" with an "Order targeting Point" (the unit group part is from what i used in my code, replace this to your own needs)
if you want to have like a rightclick hold movement style (i dont know exactly how diablo moves) you need 2 aditional trigger (you can put it in 1 but i prefer to split it up, as then you can turn off the mouse movement tracking trigger off by default to save resources)
This will run when you click the right mouse button, it will then activate moustracking in the other trigger and your unit will start following your mouse as long as you keep it pressed down. If you let the right mouse button go it will activate the trigger below, turning tracking off.
The above solution doesn't scale to multiple players, not does it answer your facing question, so I'll comment on those.
I do some similar things in my game. I store information about my 5 players in an array. Player 0 is bugged, and seems to always have vision of the entire map, so my players are #1-5 in the map settings.I have an array of size 6 (ie has slots 0-5).
Make a data type 'record' to store information about your players. You'll want to have the fields:
Make an array of appropriate size for your number of players (and i assume your player numbers are continous from 1.) The array should be of the record type you've made. Let's call the array 'players'
Now make a trigger similar to what the previous poster suggested:
Make a similar trigger RightClickOff that handles the mouse up state, and sets the variable to false. Now make a trigger to handle the right actions on mouse movement (and forgive my pseudo code, I don't have the editor available)
If there isn't an action for making a unit face a point, but rather only one facing an angle, you'd just need to compute the angle between the position of players[i].hero_ and target.