I’m developing a RTS game, and already gave some nodes representing my minions.
When I left click them, I get them enable, and when click on ground, get them disabled.
Right now my challenge is the selection box. I’ve tryed with cubes, lines but can’t find a simple way to get it working. Many problems due to world / local coordinates and height.
I’m allready saving the 1st position and last position of mouse on 2 Vector2f. Now I only need to draw something with those 2 vectors.
9-patch resizing would do the trick. Whatever GUI you end up going with will have this feature as a standard thing. You could easily adapt it to use as a selection box.
There is a simple way to get a correct selection. The perfect match is more tricky.
You’re trying to translate your selection rectangle from screen space to world space. You will find it much easier to tranlate your unit position from world space to screen space.
Now you just have to check if unit screen projection is inside you 2D box.
Does that help?
You’ll find my implementation for OpenRTS at the bottom of this class
Don’t hesitate to @mention me if you need more RTS code tricks
It’s indeed a great engine to implement RTS games, already saw. But sadly its for a university and It must be implemented by root, without using any other engine.