Can't Build New Building Type

In the Unity multiplayer course, while making the RTS, I’m trying to create a second building that spawns different units. Despite following along with the lecture, and double checking every setting I can find, when I try to place my new unit spawner (we’ll call it tank spawner), it instead places the first unit spawner (we’ll call it car spawner).

When I first click on the button and drag out the building, the preview shows the tank spawner. It’s only when it places that it switches to the car spawner. It’s not just that it’s showing the wrong mesh either; the player is charged the amount of a car spawner rather than a tank spawner, and it spawns cars rather than tanks.

Any help would be appreciated!

Hi there,
There are a couple things to check here. When you set up the new building, did you give it a unique building Id? This is what is used to reference the building when spawning it. Then on the RTSPlayer you need put the building in buildings list. Let me know if that helps!

I had forgotten to add it to the buildings list on RTSPlayer, but doing so didn’t fix the issue. The building IDs are not the same either.

Hmm if it’s not the editor setup it could be an issue in the code. Could you please share your code for the BuildingButton OnPointerUp method and the RTSPlayer CmdTryPlaceBuilding method?


Well code seems fine as well. The only thing that makes sense to me is an issue with the building Id. Would you like to upload your project and I can take a look at it?
https://gdev.tv/projectupload

Give me a shout here if you decide to upload it so I know to look for it.

I just uploaded it! Thanks so much for your help.

Hmm, I don’t see it on my end, can you try one more time please?

Did it again! Hopefully it works this time

Hi there,
It uploaded successfully.
When I went to look at your Attack Unit Spawner PRefab, the building Id was set to 1. When I set it to 3 (a unique int from the other buildings) everything worked correctly.
image

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

Privacy & Terms