Having problem with resetting the path (Unity Muyltiplayer RTS)

Hi!

It seems like the fields “remainingDistance” and “hasPath” isn’t updating properly. I skipped making box selection and didn’t refactor moving logic as you did. I am using old logic for unit movement.

Here, for distance check since you create update method with server callback, I decided to make a server function which will be called in Client update since it was used for movement in previous movement logic.

Even though CmdMonitorDistance() is getting called every frame (checked via logging) the variables hasPath and remaining distance isn’t getting updated as should be. hasPath is false sometimes even when unit is moving flawlessly and remaining distance doesn’t updates. (Created those to variables to monitor the corresponding values).

Hi there, where are your debug.log statements getting called from? Can you show them in the script?

I removed it now but it was where I am initializing hasPath, the first line of CmdMonitorDistance().

Well, a little bit of refactoring solved the problem. Earlier I used return; in Update() due to which CmdMonitorDistance was not getting called when a unit was selected.
When I was checking by logging out, it logged into console when unit was not selected and I thought it was getting called every frame.

1 Like

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

Privacy & Terms