Moving Unit Trigger

Status
Not open for further replies.
Level 3
Joined
May 10, 2014
Messages
41
Hello!

I create a spell, that moves target unit by fixed distance in casters facing angle direction.

How it works:

-set distance
-set move = 'number'
-set count = distace / move

Cycle (while count =! 0)
-set point_to_move = position of target unit offset by move
-move target unit to point_to_move
-count - 1

I want target unit ''touch'' other units and decorations while it's moving, so I don't modify collision.

So... games CRASHES (not fatal error, but extreme lag, like screenshot)...

But it happening only if there is no 'free' point to move target unit, because of terrain, trees, or other units.

How can I check: is point is free to move???
And if it's not - stop moving (set count to 0).

Thank everybody for any information! :as:
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
You probably have no delay between each set position.
And when you do SetPosition, the unit will check for pathing.
If the unit cannot be placed on that spot, it will go to the best nearby spot... which is probably pretty much back where it started.

I cant think of anything else because I cannot see the actual trigger.

To see if a certain point is unpathed (able to be moved on) you create a unit on that location and check if the unit is standing there.
If he is not, then it is an invalid location.
 
Level 29
Joined
Sep 26, 2009
Messages
2,594
From what you wrote I assume you use the standard "Unit - Move unit instantly to point ..." action. This action is quite slow because every time it moves unit, it first checks if the next point (where you want to move said unit) is pathable and if not, it searches for the closest pathable point.
You may be overtaxing the game because of the loop and the game trying to figure out where to place the unit when it encounters unpathable point (tree, etc.)

I would advise using "SetUnitX" and "SetUnitY" commands to move unit. That command completely ignores all pathing (units, trees, etc.), however you can use an item trick to determine if said point is pathable. Units will be ignored so your unit will pass through other untis, however that is not much of an issue imo (they "unstuck" from one another when one unit moves).

You should read this: http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/about-movement-172309/
 
Status
Not open for further replies.
Top