Preview colours only showing on host/server

Hi all,

Everything is working fine except, on the client instance, when I drag a building preview around the screen, the colour doesn’t change. It stays the same as the buildingPreviewInstance.
The server player’s building previews are coloured correctly however.
I saw a question in another thread about something similar and the solution was to use “_Color” instead of the “_BaseColor” string to address the material’s colour. That hasn’t fixed the issue.
I’ve tried simply copying the BuildingButton script from the repository but that didn’t fix it either.
Any ideas what to look at?

thx

Hi there,
What model are you using for the building at this stage?

I’m using the generic cube with the collider removed for the UnitSpawner and a generic sphere without a collider for the ResourceGenerator. It’s been happening since all the buildings were cubes though.
The weird thing is that the green/red colour change for valid/invalid placement is fine on the host, just not the client, regardless of whether the client is in the editor or the build =\

Same problem here, currently trying to fix it. I’ve found that in the the CanPlaceBuilding() method in RTSPlayer, the if statement that checks for building range is always false when ran by the client, hence why the building preview is always red. That’s the case for me at least.

After a lot of announcement debugs I think I have found the problem:
In RTSPlayer make sure the AuthorityHandleBuildingDespawned function is removing the building from the myBuildings list and the AuthorityHandleBuildingSpawned is adding the building to the myBuildings list.
I think what happened was while I was copy/pasting these subscriber functions I must’ve mixed up what they’re supposed to do.

1 Like

Hmmm, I had that method set correctly already and I still have the problem…

Interesting. Do a print(myBuildings.Count) at the top of the CanPlaceBuilding() function, and see if it lists the right number of buildings.

Thank you! I did that, and for some reason the client always had their buildings at 0, turns out that when I was unsubscribing from the spawn/despawn events I put “spawned” instead of “despawned” for the despawned event, so it was messing it up. It’s fixed now :slight_smile:

2 Likes

Awesome! =)

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

Privacy & Terms