Posted January 10, 2024 by greenflysau
Units can now move into the city. This is a precursor to taking a city in combat. For now they can just move into it.
I removed alpha/transparency from the tank icon so it looks better when its icon is over the city icon. In this case, I minified the tank icon so you can still see the city underneath.
Interesting corner case: if a unit is already in a city, the Godot ray cast randomly returns either the city or the unit. One approach is to raycast multiple in a loop, with exceptions. Great, except this breaks when the ray target is terrain. I get an error about unexpected node type.
After spending an hour trying to figure that out, I have given up for now. Instead I handle either case: if ray cast hits a unit, deny. If ray cast hits an occupied city, deny. If ray cast hits an unoccupied city, move.