Error with selection while testing [SOLVED]

Hello! seems like I am asking a million questions today but I am hoping for some help again. I just finished the lecture “Unit Targeting” and when I went to test I ran both the build of the game and in the Unity Editor as usual.

However whenever I click join on whichever I choose to be the client(doesnt matter if build or editor) the unit selection goes all weird, with a couple different bugs that all seem connected. Whenever the player that is client only tried to spawn a unit, the unit spawns. However, the green selected sprite only shows up on the host screen, and the client-only player has no control over their unit.

Both the build and editor appear to work as expected before joining each other and also after breaking literally everything earlier, I had just clones the GitLab project up to this point, so I have no idea what is wrong. Thanks for any help!

Hi there,

There is a feature in Mirror since the course was launched and the Repo was set. This feature activates all renderers in networkObjects after start(). There should be a fix patched to this lecture video or the next. If you can’t find it, the idea is to activate/deactivate the gameObject with sprite instead of the enabling/disabling the sprite renderer directly. You can set this in the unit prefab through the unity events, the same way we did using the sprite renderer, just update the events. Let me know if you need more help figuring it out.

Ahh yes I do remember that, it was a few lectures ago so I didn’t even think of it haha. Thanks!

The sprite is now selected properly at the right time, though it seems like for whoever is client only, it takes a couple of clicks to actually get them to move? And I dont remember at all if it is suppose to be like this but when selecting an already selected unit, I thought it would deselect them, but it just reselects them it seems. Sorry, idk how related that is to the sprite renderer stuff but they may be connected

EDIT: I disabled the selection circle gameobject on the Unit prefab as was suggested in another Q&A, so not the unit is deselected on spawn, which is not correct, however, I select it once and then it can move so it is more than functional to continue to work with, plus I saw we’ll adjust the spawning anyhow

1 Like

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

Privacy & Terms