RTS-Style Drag Select, Click to Select/Deselect, and Movement | AI Series Part 26




Published: 31 Aug 2021

Learn how to implement RTS-style drag selection, point and click selection, shift+click to select and deselect new units, and issue movement commands! This is sometimes also called "box selection".

You'll also learn how to configure a SelectionManager singleton class that controls which units are currently selected, as well as automatically self-registering SelectableUnits.


In AI Series Part 26 we'll be covering how to do all of the above RTS-style features and discussing the "gotchas" that are easy to run into when implementing the drag selection.


We'll be using 2 key functionalities of the Camera class to achieve this:

⚫ Camera.ScreenPointToRay to do Raycasts from the Camera.

⚫ Camera.WorldToScreenPoint to determine which SelectableUnits are within our selection box.


As usual with the AI Series, we're using the NavMesh Components: https://docs.unity3d.com/Manual/NavMesh-BuildingComponents.html not the built-in navigation system.


🔶 ALL THINGS LlamAcademy now available at: https://llamacademy.dev/support including latest tutorials, courses, ways to support, and more! Check it out 🙂

👨‍💻 Get the FULL FREE PROJECT on GitHub: https://github.com/llamacademy/ai-series-part-26

🏷️Save 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?section=personal&billing=yearly


Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.


Connect on Social Media

Some links may be affiliate links, which at no additional cost to you, gives LlamAcademy a small portion of the purchase.