Problem/bug in 'Selecting a Unit' video in 'Real Time Strategy' course

Client selection Circle not functioning correctly.

Hi there,
In this lesson I have followed the instructions as closely as possible.
At 4:02 Nathan mentions that in future versions of Mirror those bools will not work correctly as they will automatically be turned on. I have version 40.0.9 of Mirror, Version 2020.3.10f1 of Unity.

As this was a problem for me, I used the alternative of ‘GameObject.SetActive()’.
However, this has brought up a different bug.
Selecting and deselecting works as normal for the hosting build.
The ‘client only’ build can create units fine. However when they are created they are automatically highlighted by the green circle in the host machine, and there is no green circle shown in the client machine.

Using the client to select and deselect will select a unit and move it, but it does not alter the above state for the green circle. Hosts are not able to actually select and move client units. Yet ALL client units will have their green circle set to active in the hosts game, and set to inactive in their game, regardless of what state they are in.

Would it be better to set the colour to transparent and back again in this case, rather than using Unity Events?

I did complete the lecture after this one before discovering the bug. I can post any code needed.


While it isn’t 100%, I’ve found a partial solution to this issue.

Instead of

public void Select()
if (!hasAuthority) { return; }

I set the colour manually with:

public void Select()
if(!hasAuthority) { return; }
this.GetComponentInChildren().color = new Color32(9, 217, 54, 255);

I replaced the “onDeselected?.Invoke();” line with

this.GetComponentInChildren().color = new Color32(255, 255, 255, 0);

This sets the selection circle to transparent.
I also added a start method so that the unit does not start with the selection circle showing when the unit is instantiated. This was really important because without this all enemy units would have green circles around them when they spawned in, regardless of what you selected (this was the issue I was having with the provided solution in the video):

public void Start()
this.GetComponentInChildren().color = new Color32(255, 255, 255, 0);

I hope this is of use to someone, and doesn’t cause a problem for me down the line.

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

Hi there,

This is an interesting solution, glad you found something that works. For the events/gameObject solution, did you set the the sprite gameObjects to be inactive in the the prefab, and the sprite renderers enabled?

Privacy & Terms