| 04-15-2006, 10:47 PM | #1 |
Right, I need to come up with a system that would allow me to move a unit by triggers to a targeted point. That would also involve it going around obsticles and choosing the shortest path around said obsticles. And I'd like to avoid having to plot the entire course if possible. That being said, I need conceptual help, I can do the triggers easily, but I'm kinda lost on just how to go about it That said, any help would be appreciated! Edit: The more I think about this, the more convinced I am that I'll have to plot the unit's course beforehand. Bearing that in mind, I still need a viable way of doing this, so back to mulling... |
| 04-15-2006, 11:45 PM | #2 |
i had made a concept for this once, but forgot where i put it, let me find it... |
| 04-16-2006, 02:08 AM | #3 |
I'm not quite clear on what exactly you're trying to do, that you can't just do Trigger: Unit - Order ThisUnit to Move To (Center of (SomeRegion)) |
| 04-16-2006, 10:13 AM | #4 |
Ok, this is what i had in mind, a trigger that periodically moves a unit towards target point until it reaches that point. The catch is that I want it to go around obsticles in an intelligent manner, that clarify things? |
| 04-16-2006, 11:20 AM | #5 |
Depends, you could make a really fast unit run through the path before-hand and take a bearing on where that unit is every second or so, then move the unit you want to each position whenever. Or you'd have to plot the path beforehand, unless theres some sort of sneaky JASS trigger. Actually, now that i think about it, just order the unit to move to the target location and then order it to stop after X seconds. Simple! |
| 04-16-2006, 11:50 AM | #6 |
Look, I don't want to order the unit to do anything, I wanna move it with a trigger, hence the problem of putting it on a walkable path. A reasonable walkable path that is |
| 04-16-2006, 12:17 PM | #7 |
To find a walkable path, you would need a pathing system. A* (I think that's what it was called) is an efficient variant of Depth First Searching, and would probably your best bet. However, trying to implement something like that in JASS would not be fun (making a BFS certainly wasn't for me). Could you possibly explain why you need this, because it is possible that there is another solution to your problem. |
| 04-16-2006, 12:27 PM | #8 |
The only way to do that is use the CheckPathability trick by vexorian. Put an item on the next X/Y coords you're moving the unit to. Then get the X/Y of the item. If the x/y of coords != x/y of the item, it's not pathable. Then if it isn't pathable, if you want to simulate the unit going around that obstacle, you will have to use a dummy unit instead of the original unit from the start of the moving period, and then hide the casting unit, and reshow it at the end of the trigger at wherever the dummy stopped. When you reach an obstacle you will have to recreate dummies in order to make it look good, because the facing angle wont work fast enough for that. You have to recreate the dummy in the next position, increase the angle a bit on each movement and when you create it, create it facing the increased angle. Then when the angle reaches lets say, 45 degrees, start reducing the angle until you get to the angle of the original angle you were moving the unit to. then the new dummy at the original angle can be kept on moving without recreating dummies. It takes alot of tests to see how much to increase the angle and when to reduce it, and a number of conditions. This is the best and most reasonable way to do that, since I already did something very similar once. Also I suggest that after increasing the angle, check the angle between that angle and the unit, and check pathability again to the specified next movement, to see if the obstacle is wide or not. Just alot of work and thought but its not impossible. I hope this helps. |
| 04-16-2006, 12:34 PM | #9 |
It helps, I was thinking of something along those lines vile, but it also confirms my fears that a system like this would be too complicated to be practical, so unless I can come up with something simpler, I'll have to drop the idea. @blu_da_noob, I wanted this system so I could use it for some heroes on a map, as it would allow me to do some cool stuff if I could get it to work. The main reason for using it is 'cause of the stupid limitations of the movement system in WC3, as in all the stacking issues and movespeed limit and such |
| 04-16-2006, 12:35 PM | #10 |
How do you plan to find which way to turn/move with that method, Vile? Also, moving straight and only turning when you reach an object blocking your way won't provide the shortest path (most of the time). Edit: (cross posted with Mezzer) The reason that there is a cap on unit movement speed is because the pathing algorithm blizzard uses (and you would need to use on to find the shortest path) can't handle speed greater than 522. |
| 04-16-2006, 12:37 PM | #11 |
With checking pathability on each movement you can detect whats pathable or not and increase the angle when it isnt, decreasing when it is. You can't really tell the shortest path unless you pre plan the whole path which is even a more headache than it is. |
| 04-16-2006, 12:43 PM | #12 |
U could try making a loop which increments an angle and checks both + and - that angle from your current facing until it finds a pathable square. It would then move the unit in that derection and continue in that manner. Sadly, that does not equate to the shortest path in a lot of cases |
| 04-16-2006, 02:38 PM | #13 |
Actually I gave this a thought. What about checking the distance between points, between certain angles, rotating 180 degrees around in front of the casting point, lets say every 15 or 30 angles checking, and then check each line for pathability on each 35 radius, and then if its not pathable, decrease the distance for some amount, then keep on checking that line, and move to other lines. the line that has the longest distance should be chosen and moved into. Its what I can think of right now. |
| 04-16-2006, 04:12 PM | #14 |
And then repeat each time trying to get closer to the target point? I think I got what u meant, but, let me give you an example (a simple, badly drawn example) in which I think that method would give a bad result. In the example you'd have to get from point 1 to point 2. What's to stop the unit taking the blue, and way longer, path? |
| 04-16-2006, 05:43 PM | #15 |
Well, i'm lost of ideas, the only way is not to do it with triggers, only the warcraft engine can do that, when ordering a unit to move. The best thing I can think of is moving the caster and when he reaches an obstacle, just stop the trigger and order it a normal move. |
