Unity Multiplayer and Networking Course Bug

Hi all, just an issue with the rts course. I have found that if I select too many units, some units at random decide that they are going to stay where they are. Any advice to stop this?

Hi there,
I would curious if you are able to narrow down the source of this issue. Are the units being selected and added to the list of selected units on the RTSPlayer? Is their move command successfully being called? Most likely yes, but always good to double check those things.
I wonder if this is an issue with the navMesh. If they see no route to the move location, because too many units are moving, they will not move. One of things we do not cover in this course, is creating a movement method that gives the units different locations to move to depending on how many units are selected.
For example, if you have ten units, you should call CmdMove and pass in the suggested location. CmdMove should then find 10 nicely spaced out locations with the original location at the center. Then each units would be told to move to a different location. This would allow the units to not collide as much, and also have them assemble in formation.

Hi,
I did some debugging and found what I think the issue is. If a unit is close to its destination, in the unit movement script, it clears the units path. So in rare cases it clears the path as soon as the unit gets a new path causing it to not move. At the moment I have just removed that piece of code and all seems to be working but I would think that there would be a solution to this and that you probably want to update at least that 1 video of the course so no one else has to go through this hassle. Thank you in advance for helping and have a lovely day :slight_smile:

Glad you figured this out, can you share the line the of code where you made the change?

Its a pretty lazy fix but it works for now

What is your stopping distance set to? Maybe you just need to decrease the value of the stopping distance?

originally it was set to 0.75 like the course said, but I did try increasing and decreasing it and it still didn’t fix the issue. Now to compensate for my lazy fix to the bug it is set to something like 4

Is the stopping distance [SerializedField] in your script. If so, you will need to change it in the editor and not the script. Just wanted to check that it was actually changing for you.

Yup! I had done that and it was changing

1 Like

Changing the stopping distance still doesn’t fix the issue

If you make it like super small, 0.001f, is it still clearing the path?

without my lazy bugfix?

without my lazy bugfix it still with the small stopping distance will not work
not working

Well that makes no sense lol, how could it rest the path, your unit is clearly more than 0.001f away from the spot you clicked.

Can you debug.log agent.remainingDistance and agent.stoppingDistance?

Welcome to my world

the remaining distance is 0 and the stopping distance is 4 according to the debug statements

Well if the remainingDistance is 0, either the path has been reset already, or it was never set to begin with.

That is what my fix does. That line of code is clearing the path of the unit before it finishes generating its path meaning it doesn’t move. Now I have just commented out it to fix it but there must a better way to fix it

And if either of these would be the case then why would some move and others not

Privacy & Terms