When I drag a new building the colour very, very rarely changes. There’s only 1 other building in the scene (I’m only running it direct from Unity as a Server + Client). I added some debug code which shows that the sqrMagnitude results are all over the place. Here’s the debug for when it works:
RTSPlayer::CanPlaceBuilding, point: (6.0, 0.5, 8.8), building.transform.position: (8.0, 0.5, 8.0), buildingCollider.center: (0.0, 0.5, 0.0), this.buildingRangeLimit: 5, (point - building.transform.position).sqrMagnitude: 4.805718, (this.buildingRangeLimit * this.buildingRangeLimit): 25
Literally with the next move of the mouse I get:
RTSPlayer::CanPlaceBuilding, point: (4.7, 0.5, 5.5), building.transform.position: (8.0, 0.5, 8.0). buildingCollider.center: (0.0, 0.5, 0.0), this.buildingRangeLimit: 5, (point - building.transform.position).sqrMagnitude: 16.7137, (this.buildingRangeLimit * this.buildingRangeLimit): 25
I’ve double checked the code with what is in the files from the final lecture in the course and they match.