- Joined
- Aug 8, 2010
- Messages
- 1,022
Hi! how i can make a unit move randomly around the map every second? please help! +rep for helping me! 
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Events
Map Initalization
Actions
Variable - Set movepoint - position of Unit
Events
Time - Every 0.01
Actions
Variable - Set range - Distance between position of unit and movepoint
Events
Value of real variable - range less than or equal to 50
Actions
Variable - Set movepoint - random point in region
Unit - order Unit to attack move to movepoint
Trigger
Events

Time - Every 1.00 seconds of game-time
Conditions
Actions

Set Points[1] = (Position of (Your unit))

Set Points[2] = (Points[1] offset by (Random real number between 150.00 and 300.00) towards (Random angle))

Unit - Order (Your unit) to Move to Points[2]

Custom script: call RemoveLocation (udg_Points[1])

Custom script: call RemoveLocation (udg_Points[2])
Trig 1

Events


Time - Every 1.00 seconds of game time

Conditions

Actions


Trigger - Run Trig 2 <gen> (ignoring conditions)
Trig 2

Events


Unit - A unit enters Region 000 <gen>

Conditions

Actions


Set Points[1] = (Position of (Picked unit))


Set Points[2] = (Points[1] offset by (Random real number between 150.00 and 300.00) towards (Random angle) degrees)


Unit - Order (Entering unit) to Move To Points[2]


Custom script: call RemoveLocation (udg_Points[1])


Custom script: call RemoveLocation (udg_Points[2])

but every second the point is set.The unit would walk and stop on the spot.the trigger i mentioned runs a check on whether the unit has reached the area and generates an area afterwards.
Trigger
Events
Time - Every 1.00 seconds of game-time
Conditions
Actions
Set Points[1] = (Position of (Your unit))
Set Points[2] = (Points[1] offset by (Random real number between 150.00 and 300.00) towards (Random angle))
Unit - Order (Your unit) to Move to Points[2]
Custom script: call RemoveLocation (udg_Points[1])
Custom script: call RemoveLocation (udg_Points[2])
Still, "every 0.01 seconds" is NOT good: I always use every 0.032 seconds (JASS), or every 0.03 seconds (GUI).but every second the point is set.The unit would walk and stop on the spot.the trigger i mentioned runs a check on whether the unit has reached the area and generates an area afterwards.

