OpenSAGE / OpenSAGE

OpenSAGE is a free, open source re-implementation of SAGE, the 3D real time strategy (RTS) engine used in Command & Conquer: Generals and other RTS titles from EA Pacific. Written in C#. Not affiliated with EA.
https://opensage.github.io
Other
1.39k stars 131 forks source link

Add pathfinding #296

Open feliwir opened 5 years ago

feliwir commented 5 years ago

When units are moving they should use pathfinding to navigate to their target location. Use an A* based pathfinding algorithm. See e.g. https://github.com/Robmaister/SharpNav

feliwir commented 5 years ago

So here is a more in depth list of what needs to be done:

  1. Create a navigation mesh once the terrain gets loaded: Probably want to look into MapLoader.cs at LoadEntry for this part (a Scene3D should contain a navigation mesh)
  2. When a movement command/order is generated we want to to get a List of points for the navigation path. So the Scene3D class (maybe?) should have a method to calculate such a List for 2 points.
  3. The GameObject.cs already has a MoveTo method, but instead of just moving directly to the target point it should call the method described above to get list of waypoints it must walk pass for correct pathfinding.
  4. In each LogicTick the GameObject must check if the next waypoint was reached and remove it from the List if that's the case.

As i said above i think an extern library for the pathfinding part might make sense here

feliwir commented 4 years ago

Works mostly. Other gameobjects are not recognized as obstacles yets. Needs more work