Tower Defense Multiplayer - complete networking project (Netcode)

Thank you for the fast reply, that did it :slight_smile:

I did find another issue, in “Map_UI > Canvas > Panels > Panel - Info” it shows “Player 1” info for all, it should be that all players can see their own currency, score and health.

In this print The Editor have 50 coins but in the UI in the GameView it says it has 10 (as Player 1 have)

Thanks @PixelPirates , looking into this. I have fixed a similar issue before releasing the asset, will have to try and reproduce it again. It could be that it only occurs when running multiple instances on the same machine, or with a different Network Transport version. Investigating and will report back very soon.

1 Like

I asked a friend to join in to try remote multiplayer and we had the same issue even tho we are on different networks so thats not the issue here.

Edit: The project in the print is without any edits to the asset, I have a project just to reflect back on if something is behaving wrong in my project I can go back to the base asset to see if there is a problem with my edits or in the asset.

Edit: All players also spawn in as player 1 on the spawn location.

@PixelPirates Thanks for the confirmation. I have resubmitted version 1.0.1 which now includes fixes to the issues you have mentioned as well. It is live via GitHub access now and probably somewhen next week on the Unity Asset Store.

v1.0.1

  • fixed wrong Layer settings in TagManager breaking tower placement
  • fixed bug spawning all players on same location due to incorrect local client ID
  • fixed bug displaying player 1 stats to all players due to incorrect local client ID
  • fixed hiding mobile scroll indicators on WebGL build
1 Like

Do you have any ETA on when the rest of the documentation will be added? It says “Documentation for this page will follow in the upcoming 1-2 weeks” but last update was on oct 27 so it has been more then 2 weeks.
I have ran into a problem where the upgrade panel isnt showed when clicking on a built tower but I cant figure out why and what scripts that actually relate to this.

I have planned to finish it this week (working on it right now). It was scheduled for earlier this week, but releasing version 1.0.1 was more important.

Please note that the “Feature” section in the documentation is more a general description of a feature and what it does, rather than how it works (due to public documentation). The components involved and workflow across scripts will be mentioned though.

As a first stop, you will want to check the Update() function in UIGame.cs, at the bottom where RaycastTower() is called and verify that the raycast actually hits something. If that is not the case, check that the Tower has a collider on the “Tower” layer.

1 Like

Thanks for the help, my miss was that I had named the “Tower” layer “Towers” but I found the error thanks to your description. Just adding this comment if someone else in the future does the same misstake as me :slight_smile:

1 Like

I have made an effect for selected tower but something is not working with the poolmanager and I am not sure what is wrong.

In the ShowTowerUpgrade() I have the following line:
PoolManager.Spawn(selectedFX, trans.position, Quaternion.identity);

and in the Upgrade, Sell & CancelAction() I have the following line:
PoolManager.Despawn(selectedFX);

and I have added the prefab in the PooManager as a Pool:

But I still get error:
“PoolManager couldn’t find Pool for instance: Selected FX”
&
“NullReferenceException: Object reference not set to an instance of an object
TowerDefenseMP.PoolManager.Despawn”
but the effect is Spawned as it should but when I “deselect” the tower the effect is not deactivated.

Is the gameobject value you are passing in the same in both methods? Because then it won’t work. Spawn is expecting a prefab, while Despawn expects an instance as the method parameters tell:

Spawn (GameObject prefab, Vector3 position, Quaternion rotation)
Despawn (GameObject instance, float time=0f)

Since your prefab is not an instance of a pool - it’s a prefab. You would want to cache the gameobject instance returned from Spawn() and pass that into Despawn().

1 Like

Silly me, thanks :slight_smile:

Some functionalities I would like to see in future upgrades (if you want to improve the functionalities):

  • A way to set available classes depending on map chosen in lobby (and even change max players for lobby depending on map).
  • Tower effects (slow and aoe attacks etc).

Hi @PixelPirates , I was on vacation the last week without access to internet, so was unable to respond. Thanks for your post.

Also answering your PM: while I have a small list of features I would like to implement, there is no timeframe to do so. Usually, my assets receive 1-2 feature updates per year, 2-3 compatibility updates per year, and as many bug fix updates they need. Prioritization depends on popularity of the asset and I can tell that for this asset, it has not gathered enough market interest yet that would justify a bigger focus (unfortunately).

I would split this into two feature requests. The first is a very specific request that might not be a good fit for every developer - allowing to disable classes for a map, potentially a class a player has bought, could create acceptance issues. Also, I have the feeling that the ScriptableObject system required to set up classes is complex already - if you have a need for this, I would be more than happy to give you input on how I would tackle this.

Having different max players per map is something that has been on my list, but I was unsure how to handle cases where the master user selects a map that has a lower player count that the current player count in the lobby. I.e. should the players joined last get kicked out of the lobby then? Additionally I am not sure if Unity Lobby really allows for flexible max players, or if this is something that needs to be checked on the master client in code only. I have put this back on the list.

Slow is on the list, but has not made it for the release due to the way the “Unit reached end of path” logic currently works. Simply speaking, this is a fixed time value in seconds, since Unity Splines did not allow calculating it for the current Unit position on the path. When slow is applied, this time value should obviously change.
Implementing AOE damage sounds easy too, however it really isn’t: since Units do not use colliders or any physics for maximum performance, projectiles cannot do a SphereCast or something like that to detect Units nearby. I will have to think about this and maybe require adding Colliders for specific purposes like this one.

1 Like

Any plans to update to use Multiplayer Services instead of individual Lobby and Relay packages?
Your docs cite using the Unity Gaming Services instructions to install Lobby and Relay but they both point to Multiplayer Services now and for example RelayServerData as used in NetworkManagerCustom is now out of date and errors on compilation.

Thanks

Hi! If there are compliation errors, I am going to fix them of course. I have recently updated the Netcode packages for my other asset, Tanks Multiplayer, and did not see any issues with the continued use of Lobby and Relay - even in Unity 6.

Unity Gaming Services is now Unity Cloud, but that’s about it. Could you please state your Unity version so I can double check any problems in the documentation?

Thanks

1 Like

Unity 6000.0.25f1, I’ve since disabled the Multiplayer Services package but since it was today it’s whatever version is currently latest.

Hi @omeda_oz , I’ve uploaded a package for Unity 6+ which uses the Multiplayer Services package including a fix to the compilation error. It should show up on the Asset Store soon.

Confirmed packages:
Unity 2022.3

  • Netcode for GameObjects 1.12.0
  • Unity Transport 2.4.0
  • Lobby 1.2.2
  • Relay 1.1.1

Unity 6

  • Netcode for GameObjects 2.1.1
  • Unity Transport 2.4.0
  • Multiplayer Services 1.1.0

---------------------------------------------------------------------------

@all Please note that this asset will be deprecated on 01/01/25. I am still going to offer support for any compilation or dependency errors throughout 2025.
But this asset will not be available for purchase anymore and there will be no support in 2026 and beyond.

1 Like