Ok, that went more easily than expected. Yesterday, I had a couple of hours to work on the selection system for Holocene and I think I finished it, which is nice.
I made a script to handle selecting and deselecting objects for the player and made some changes to the script handling input from the mouse. As I said yesterday, the script keeps track of what object is under the mouse cursor. When the user clicks, the following things can happen:
- You click on an object. It gets selected.
- You hold shift and click on an object. It gets added to a list of selected objects. The selection script always knows what kind of objects are selected and uses that information to decide whether the clicked object will be the only object to be selected or the other selection remains. Only units you own can be multi-selected. If the current selection contains other kinds of objects (e.g. buildings or enemy units), or the object to be selected is another kind of unit, the selection is cleared and that one object is selected.
- You click somewhere on the ground and drag a box on the screen. All owned units in the box are selected.
That's it, actually. Because I don't have any GUI yet, I used the inspector to test it and it seems to work fine. In the little gif below, the big goats are owned by the player. The small ones are enemies. I try all the ways to select them. It works.
Next up will be making basic moving units. Select 'm and right click on the ground to have them move there. The goats are not supposed to be controlled. They move around on their own.
No comments:
Post a Comment