|
-
Dec 12th, 2002, 03:45 PM
#1
Thread Starter
Fanatic Member
Pathing
Lately I've been trying to create a good pathing code... well good for a intermediate-beginner..
Anyways, what I'm going on is something like this:
Instead of active pathing (constantly calculating) I just get the path at start and save it in a string, excepting when a unit gets in way, then I make a "subpath" around it.
The order would be something similar to:
*I'm using a tile system, any tile with value above X is impassable
*The unit's can move in 8 directions
-Set terrain (temporarily) to show unit has already stepped there
-start loop here
-Get angle from unit to destination, round off to nearest 45.
-start a for loop for checking movement
-Check if tile at x+int(sin(angle)+.5),y+int(sin(angle)+.5) is passable
*-If passable then move, set terrain to show unit has been here, add to string
*-If not passable then start rotating check around (if it started at 0, it would then check 45, 315, 90, 270 etc), exit for
-end for loop
-If variable of for loop is greater then 315 then back up, look for new path
-If you back up so much your back at starting point, then you can't reach, don't bother moving.
-End loop
**-Subpath between some points to check if path can be shortened
Is this a very efficient system? Or is there a better way?
Don't pay attention to this signature, it's contradictory.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|