Sunday 30th March:
First things first. I am going to be using A* Pathfinding. But before generating the route using the A* algorithm, check to see if there is a direct "Line Of Sight" path between the starting position and the target position. This was implemented first by the use of c#'s Ray, BoundingBox and their .Intercetced methods... These all handle 3D calculations, which is good for 3D, but since this app is only in 2D it does not really make sense to use it... also it wasn't giving the correct results. The only (and best) answer was to write it myself, this was good because it teaches me how to do do thinks like RayBox intersection, and other line of sight algorithm... thing-ys.
A Unit class was created in order to controll the moving of the Units on the screen. This included ablity to select a "Target Position" where the Unit will move towards at a constant speed until it reaches that position.
Once this had been completed, a new sprite was added to act as a in game object that will block the units Line Of Site thus stopping the unit from moving (The Cursor will change to represent this error) ... And now it does heehee! It was during the creating of the line of sight and navigation around the in game "Obstruction" that the idea of including waypoints in the game would be a nice addition. Thus they were added. By clicking with the mouse the first "Unit" will move to the location as long as it is within Line Of Sight, if the user holds the [Shift] key while clicking, it will create waypoint and queue up the movments. Each new waypoint must be in Line Of Sight from the last created waypoint in order to be created. If the user clicks without holding [Shift] any waypoints will be destroyed and the "Unit" will move towards this new TargetPosition.
Sunday, 30 March 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment