Interested or looking for support? Ask me anything in this thread - from developer to developer
Tower Defense Multiplayer is a new take on the popular tower defense genre, in the form of a co-op multiplayer template using Unity Netcode for GameObjects. By default, it allows up to 8 players per room, to shoot down waves of incoming enemies and compete for the highest score. It features player class selection, tower placement and shooting, upgrades, defense points with health, networked object pooling, several Unity services and more. This template is laying the ground for a successful multiplayer game, by demonstrating common network tasks such as connecting players to a lobby, fully authoritative server actions, commands & RPCs, synced variables / object states, but also monetizing players using in-app purchases and video ads to keep your servers running. I’ve included an in-depth documentation about all approaches I took while building this and commented each and every method, so you can follow along easily.
Features:
Online Matchmaking & Player Lobby
Supports Local Area Network (LAN) game discovery
Supports Offline mode (solo) Class Selection: players choose a tower class in the lobby before they ready up Synchronized Player Properties: name, class, color, score, currency balance Authoritative Player Actions: tower placement, upgrade or sell own towers Authoritative Defense Points: server calculates damage and remaining health Shared Towers: upgrade each others towers using your own currency balance Networked Object Pooling: synced client pools for enemy units & projectiles Unit Movement: making use of Unity Splines, C# Jobs System and Burst Minimap: updates and displays unit positions periodically in a RenderTexture Reusable Manager Scripts: audio, pools, Unity IAP, Unity Ads Ads: display video ads between waves (playing solo) or on game end In-App Purchases: buy different tower classes (visual or game impact)
Unity UI: menus, wave status, player scores, mobile scroll
Input for Mobile (touch) & Standalone (keyboard + mouse) Documentation: scripting reference & step by step guide
Interested in seeing what you’ve built here. I’m a Mirror guy right now and I’ve evaluated a few other net stacks, but I’m very interested to see how your template works with the new NetCode for GameObjects.
A couple of quick questions that I didn’t see answered in your checklist:
Will the template include 2d and 3d examples?
Are matches able to be played across client types (e.g. one player with webGL, another with Windows, and another on mobile iOS/Android)?
How does this template handle auth?
Is there Steam Auth? Google auth? Apple Auth?
Does this template handle persistence across matches?
Does the matchmaking do any MMR for players?
What unity version is the baseline for this template?
Optionally, do you have a low poly kits you recommend I purchase to use with the kit?
Thanks for the questions @BetaMark ! Since this is a new asset, of course I am very interested to hear what you expect from it.
The asset will include two 3D maps, one with tower placement grids only available to a specific player (+multiple defense points), and one with shared placement grids where all players can place their towers (+one shared defense point).
In the Netcode for GO version, online cross-play is supported and done using Unity Relay. In LAN that works without Relay, but firewalls need to be disabled and a desktop client needs to host the game.
Authentication has not been a focus of the asset (yet) due to no current features requiring it. Unity Relay and Lobby use anonymous authentication at this point.
No, since nothing needs to be persisted currently. Matches are real-time sessions, which are “destroyed” if the host or all players leave. In this context, note that host migration with Unity Netcode is also not supported in this asset, but featured in my other asset, Tanks Multiplayer.
There is no MMR, but that could be easily added in Unity Lobby as an additional filter criteria when searching for open matches. However the question is if you really want to have that, since players do not play against each other, but together, where MMR would not matter that much I guess.
The asset will be released using Unity 2022.3.0 (LTS) due to Unity Transport requiring at least Unity 2022.2.
Honestly I have not looking into existing 3D models that much… I am currently working on creating some for demonstration purposes myself, which go in a similar military direction as this or that one.
It is not visible on the Unity Asset Store just yet, but will probably be in a few hours. Please see the first post for a direct link to the asset (that works). Thank you!
in the demo i have everything setup. but can not place down turrets at all. everything else is setup and working for the unity multiplayer and i have populated all slots in the scripts folder in heirarchy
Unfortunately I still do not know what you mean by that. Do you mean ScriptableObject references? Like I wrote in my last reply, could you please attach a screenshot for clarification?
Without errors or further details it is impossible for me to find the cause of the problem you are experiencing. I can offer trying to reproduce this by installing your Unity version with all your PackageManager dependencies and import the asset in that environment myself. For that, please tell me your Unity version and post the contents of your /Packages/manifest.json file here.
im using 2022.3.10f1 in urp. its a fresh install to test. so whatever comes out of the box with unity and your asset. nothign else on it. i have it all setup. just when i go to place a turret. cant drag or drop one, and also occasionally get the following "
Failed to create UdpClient at port 7787: Only one usage of each socket address (protocol/network address/port) is normally permitted.
"
@xmonster0 Thank you for your additional details and screenshot. I think I have found the cause - in a new project, the layer settings have not been taken over, even if they are correct in my exported project. Please open the Layer settings (top right → Edit Layers) and make sure they are set like this, going from 10 to 15.
I really have no clue why a new project has the old layout of layers I had months ago… will have to figure that out and release an update. Hope that fixes it on your end as well, thank you for your patience!
This is a Unity Netcode error that tells you that you cannot be the host and client on the same pc. This also occurs if you are restarting the match too quickly.
This issue is the same as above. If you are the host and client on one pc, it counts as one connection which cannot be distinguished. I will try to work around this in an update, but if you would do a real-world test you would need to play the game on two separate devices.
@xmonster0 Really? That’s weird, as I have tested that map with two separate pc’s as well and it was fine. Thanks for the report, going to try and reproduce / fix this for the upcoming update too.
Really good template, something is wrong with it tho, I have tried multible times to create a new project and import this (and importing everything that is listed in the well written documentation) and I can connect etc as I should without any problems but I can not place any towers on any grid. I am running Unity 2022.3.12f1 (LTS) and I have a 3d URP Core. Any idea why I can not place any towers? I doesnt indicate on the grid at all (as it does in the web build that I tested before purchasing the asset)
Hi [mention|xXnVyydHkhrzNd1Ug/f5cg==] , thanks for posting! The issue is caused by a wrong Layer setup - an update has already been submitted to the store. But you can correct this within a minute yourself, please see this post above .