Can't place buildings after writing Building Limit code

I’ve been over my code a couple times and I’ve set all the prefab colliders and NavMesh elements to be a Y: 0.5 but my Unit Spawner still clips halfway into the floor and I can’t seem to place any buildings (they never turn green).

Fixed the clipping issue by connecting the Preview contained in the GameObject to the serialized field (I was connecting the unattached Prefab).

After testing it seems the issue is that I can’t place anything once I add the line:

if (!CanPlaceBuilding(buildingCollider, point)) { return; }

Hi George, please check that your building list is being populated on the RTSPlayer. You can serialize it and see if it’s being filled at runtime. Usually this is the cause of the building limit not working. If the list is empty, double check all your building event subscriptions in the RTSPlayer script. Make sure all the spawns and despawns are right and all the +/- are right.

1 Like

Thanks! Turns out I was using Building.ServerOnBuildingSpawned += ServerHandleBuildingDespawned.

After I made the change to Building.ServerOnBuildingDespawned += ServerHandleBuildingDespawned. everything works as intended.

3 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms