Git Product home page Git Product logo

rtscontrols's Introduction

RTSControls

Author: Zachary Hoefler

This unity project implements basic RTS-like controls for units. Units use pathfinding to avoid obstacles on the way to their destination, and are able to be put into formations.

NOTE: The current implementation is super slow to calculate pathfinding. The code was written for clarity as an example/starting point rather than for performance.

Input

  • Drag the left mouse to select units
  • Right Click or Spacebar: Move units to mouse position
  • Number 1: Arrange units in line formation
  • Number 2: Arrange units in staggered formation
  • Arrow Keys: Pan the camera

Implementation

  • Pathfinding is done using the A* search algorithm.
  • The collision grid used for pathfinding is created on startup via the CollisionGridGenerator class. It essentially does a bunch of raycasts on the Obstacle layer, and if it hits something, that space is considered blocked. If nothing is hit, the space is assumed to be open for movement.
  • If a unit's destination is invalid, the generated "path" is just their start position to prevent the unit from attempting to search the entire map for a non-existent path before finally realizing there is none.

Future Goals (To-do list)

  • Implement jump point search for pathfinding. Significantly speeds up A* pathfinding!
  • Make formations more robust. Currently, they'll only work on units not in motion to a destination as setting the formation conflicts with their pathfinding.
  • Better artwork than cubes :)
  • Networking! First step would be making the simulation entirely deterministic. Second is setting up networking by synchronizing input. (Most RTS games implement networking this way)

rtscontrols's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.