Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Tanks Multiplayer - complete networking project (Netcode, Photon)

Discussion in 'Assets and Asset Store' started by Baroni, Jun 11, 2016.

?

Which networking solution would you like to use with this asset?

  1. Unity Networking

    136 vote(s)
    51.5%
  2. Photon Networking

    98 vote(s)
    37.1%
  3. Other

    30 vote(s)
    11.4%
  1. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    1 player starts (hosts) a game, that's all it needs. Then other players can join.

    #27

    See our roadmap link in the first post.
     
  2. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    Thank you. Is it possible to make cubes (the walls) that are destroyable and others not ?
     
  3. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    This asset is a template built with several modular components. You can (and should) extend the base project with whatever comes to your mind.
     
  4. johny256

    johny256

    Joined:
    Mar 3, 2015
    Posts:
    258
    add please 3rd camera real shot and real explosion player,add
     
  5. Rockroll

    Rockroll

    Joined:
    Aug 2, 2015
    Posts:
    6
    Hallo Baroni, I just bought your asset, I setup my project according to your instruction PDF, and I also finished setting my Unity multiplayer configuration, then I want to test the multiplayer mode, so I build a apk to my mobile, and run the simulation on my pc, I find the both can go into the game scene but the two tanks can not see each other, just like established two seperated host game. So, did I miss config something? PS: I did not change any code. Thanks.
     
  6. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @Rockroll, it is difficult for me to remotely find the cause of this. From what you've said, it looks like both instances created a separate room. This could be because your devices did not find each other on the first try. Have you been able to start two instances on your pc and joining the same room?
     
  7. Rockroll

    Rockroll

    Joined:
    Aug 2, 2015
    Posts:
    6
    I have tested the two instances running on my pc, but they are still not in same room.
     
  8. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    I have just tested two instances on one pc (one in the editor, the other one standalone) to make sure it's not caused by the UNET servers or something like that. Both clients can find each other as expected running on Unity 5.4.0f3. Looks like I am not able to reproduce your issue.
     
  9. 12234234234234

    12234234234234

    Joined:
    Feb 25, 2013
    Posts:
    2
    Hi @Baroni, I have checked "Use Host Migration" in Inspector but when i turn off player (host) all player disconnect only 1 player reconnect or change to new host. I see you note in document "UNET does not support host migration via online matchmaking yet". How to fix this problem?
     
  10. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi, there is nothing you or I could do to "fix" this. At the time of writing this, host migration for Unity Networking works over LAN games only. They simply didn't implement it for their matchmaking service. See this post for a UNET roadmap by Unity.

    If you need host migration for this asset, you ultimately have two options: switch to Photon when I'm done integrating it in a few weeks, or wait for the official UNET matchmaking host migration support to arrive eventually.
     
  11. 12234234234234

    12234234234234

    Joined:
    Feb 25, 2013
    Posts:
    2
    ok thank you!
     
  12. wilwilwil

    wilwilwil

    Joined:
    Jul 27, 2012
    Posts:
    19
    Hi, I bought the asset.
    But there are turret rotation jitter, when second player joins the battle.
    Is there any remedy for this?
     
    Last edited: Oct 7, 2016
  13. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @wilwilwil, thank you for your purchase. I guess you have started two instances on one pc, that's why you are effectively controlling both turrets thus the jitter. This does not happen when playing one game only (you can try with your phone and pc).
     
  14. wilwilwil

    wilwilwil

    Joined:
    Jul 27, 2012
    Posts:
    19
    Thank you for the quick reply. But the turret rotation jitter happens when second player connects via mobile phone (using cellular data network). Second players turret does not jitter in first player's screen, but jitters in her own screen.
     
    Last edited: Oct 10, 2016
  15. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Sorry for the delay @wilwilwil. I was able to reproduce the jitter on my mobile phone. The turret rotation is actually smoother on the server, than on the own (phone) screen, just as you described. At this point I can only guess that the server somehow tries to override the turret rotation for the player and therefore sends some interfering updates. I will investigate this more and report back very soon with a solution!
     
  16. VuHuyHoang

    VuHuyHoang

    Joined:
    Jun 29, 2016
    Posts:
    6
    Hello !
    I was buy your assert: Tank Multilplayer and a newer at Unet. I have a question:

    - Why only one main camera but it can follow varies tanks. I have watched some tutorial videos on

    youtube, i found that i must create camera for each player. Can you explain that for me?

    Thanks very much.
     
  17. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Answered via email (since you've cross-posted your question here, to our own forums and wrote an email at the same time).
     
  18. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97
    Hello, i have some questions.
    Is multiplayer only in LAN possible? Can i play over WWW?
    Do i need some external packages to get this asset running or will it work out of the box?
     
  19. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @knuppel,

    both online and LAN play is possible. This asset only uses Unity components and services, no third party packages are needed. After following the quick setup instructions (~10 minutes) the multiplayer part is ready to go.
     
  20. Xain

    Xain

    Joined:
    Aug 3, 2013
    Posts:
    68
    Hello , first of all nice asset I'm planning to buy it but I have 2 questions ;
    1-)Is this asset can work with Steam Network ?
    2-)Is it possible to add Player profile and rank system ?
     
  21. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @Xain,
    1. this is not built-in, but it could work in combination with e.g. this asset.
    2. see #34.
     
    Xain likes this.
  22. Xain

    Xain

    Joined:
    Aug 3, 2013
    Posts:
    68
    Allright I'm not master coder but I'll try my best :D , thanks for your answer.
     
  23. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Version 1.1 is live on the Asset Store:

    - added menu item in settings for the desired network mode (online/LAN/offline)
    - added AI bots with player detection when playing in network mode 'offline'
    - added support for automatic LAN discovery, host & join in network mode 'LAN'
    (when playing in a LAN on desktop Windows/Mac the firewall needs to be disabled)
    - added aim indicator on mobile devices that better visualizes the turret direction
    - changed cursor in editor and standalone builds to a crosshair style cursor
    - fixed shooting imprecision on desktop when playing in a non-square aspect ratio
    - fixed turret jittering where server could overwrite local turret rotation
     
    Xain likes this.
  24. iCode

    iCode

    Joined:
    May 25, 2013
    Posts:
    33
    Looks like a great asset! Quick question though, is your movement authoritative with client side prediction?
     
  25. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Thanks, @iCode! Movement is not authoritative at this point, but things like shooting and consuming powerups are.
     
  26. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97
    There seems to be a problem with this apk in google play store:
    "
    Sicherheitswarnung

    Die Implementierung des WebViewClient.onReceivedSslError-Handlers in deiner App ist nicht sicher. Weitere Informationen, darunter die Frist zur Behebung der Sicherheitslücke, findest du in diesem Artikel der Google-Hilfe.

    Angreifbare Klassen:
    • com.cm.androidforunity.WebActivity$3
    Betrifft die APK-Version 4."

    English (translated by google):
    Security warning
    The implementation of the WebViewClient.onReceivedSslError handler in your app is not secure. For more information, including the deadline for resolving the vulnerability, please refer to this article in Google Help.
    Accessible classes:
    Com.cm.androidforunity.WebActivity $ 3
    Applies to APK version 4.

    Article: https://support.google.com/faqs/answer/7071387

    From 25. November they will block any apk with this class.

    Any solution for this?
     
  27. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @knuppel this is not coming from our code but from Unity IAP. Please follow the official thread in the Unity IAP section for updates on this matter.
     
  28. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97
    Yes, two player can play against each other.
     
  29. knuppel

    knuppel

    Joined:
    Oct 30, 2016
    Posts:
    97
    Hello developer team,

    I'd like to send a message to my server when a user joins the arena. In which C# script could i do this?
     
  30. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    All UNET player handling code is in the NetworkManagerCustom script. See OnClientConnect or OnServerAddPlayer.
     
  31. daniel10301994

    daniel10301994

    Joined:
    Feb 23, 2016
    Posts:
    4
    Hello!

    I recently purchased this asset. I have set up multiplayer services on Unity, but I can't seem to join a room created by someone on a different network. For example, I can host a game and enter that game from the same PC. However when I try to join that server from a computer on a different network, it simply creates a new room.

    Could you please help me out with this issue? Thank you!

    Edit:

    Adding on to the above issue, here are some of the other issues that I am facing.

    2. I can use my phone and pc using Online mode to play eachother. However in this case there is 1~2 second delay on the client device when shooting bullets.

    3. When using LAN mode, pc and mobile cannot meet eachother.

    Apologies for such a long question, and apologies again if these are problem that have been addressed already elsewhere.
     
    Last edited: Dec 3, 2016
  32. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi @daniel10301994, thanks for using our asset! Your questions are difficult for me to answer, because I can't look into your pc/device network settings or anything like that (obviously). So I'm trying to answer them in a more general sense.

    1) Depending on where you and the counterpart are located, it could be that Unity Networking uses a different matchmaking server for both networks, thus not being able to find each other. As you wrote that it works via phone and pc, this doesn't seem to be an issue related to the asset.
    2) Again, location and distance to the matchmaking servers are of importance, but also the network speed and execution time of your device. Wifi and cellular data networks are typically slower therefore network packages can't be delivered that fast. However, I was not able to reproduce such a delay when testing on my phone connected via wifi (in Germany).
    3) The documentation has a hint on that, but to repeat, please make sure that you have disabled any firewalls on your pc. Broadcasting and detecting games in local networks does not work in Unity Networking with a firewall enabled.
     
  33. sorata84

    sorata84

    Joined:
    Feb 4, 2016
    Posts:
    5
    hi, just bought your asset, can i use my own server to this asset and trial unlimited ccu? thanks dev
     
  34. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hello @sorata84, currently UNET does not support running your own servers with matchmaking and relay on them. You can host a game in LAN mode though, because that does not consume CCUs. Please refer to this post which is still valid for the most part.
     
  35. sorata84

    sorata84

    Joined:
    Feb 4, 2016
    Posts:
    5
    can you add co-op mode vs bot the next update? there would be nice. thanks
     
  36. sorata84

    sorata84

    Joined:
    Feb 4, 2016
    Posts:
    5
    i have some problem when playing on android wan 4 player. sometimes the player other than server dissapear and cannot do anything else except close the game and start over again. can you fix this error because really anoying. thanks dev.
     
  37. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hello, thank you for your feedback. Basically with co-op mode you mean online/LAN in the same team with bot scene objects, correct? I guess that would be something for the future, because there are structural code changes necessary for that one. Of course I can give you input on how to implement this yourself.

    For your second message, disappearing players usually mean that their connection to the host dropped. Could you please send a more detailed description with network details (LAN/online, error on the disconnecting device?) to the support email. But for the record - if the connection does get interrupted, then there's nothing I can actually do about it.
     
  38. Zenithin

    Zenithin

    Joined:
    Jun 7, 2016
    Posts:
    35
    Just purchased this! Looks great :)

    I am eagerly waiting for the Photon Support to be added.
    Am I right in assuming that Unet works on basis of one of the player hosting the game.
    So if that player leaves/disconnects then all others would drop from the game:?
     
  39. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Thank you for your purchase @Zenithin! It's not much longer now for Photon support to arrive. You are correct with the first part of your assumption, but host migration is in place for UNET LAN mode - thus no connections are lost with a leaving host there. For relay/online matchmaking, host migration is still something Unity is working on.
     
  40. scottlaforge

    scottlaforge

    Joined:
    Mar 12, 2013
    Posts:
    42
    Hoping for some help. I'm running Unity 5.5.0f3 and am getting errors when referencing the UnityIAPManager regarding purchasing scripts. I looked at your #2 in the FAQ. My In-App Purchasing Services seem to be up to date. I even tried re-importing. Are there any known issues with v5.5 of Unity? Thanks in advance!
     
  41. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
  42. scottlaforge

    scottlaforge

    Joined:
    Mar 12, 2013
    Posts:
    42
    @Baroni Here are the the 12 errors displayed in the Console window.They all seem related to the UnityEngine.Purchasing not being referenced correctly.
    upload_2016-12-27_9-24-54.png
     
  43. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Looks like it can't find the Unity IAP scripts at all. Are you sure you've imported the Unity IAP billing plugin into your project? They should be located in the Plugins > UnityPurchasing folder after that. Maybe also try deleting that folder and reimporting from the services panel.
     
  44. scottlaforge

    scottlaforge

    Joined:
    Mar 12, 2013
    Posts:
    42
    @Baroni Here's what I'm seeing in the Plugins folder and the Unity Ads folder. I will try deleting and reimporting again. Thanks for your advice.
    upload_2016-12-27_9-43-23.png
     
  45. scottlaforge

    scottlaforge

    Joined:
    Mar 12, 2013
    Posts:
    42
    @Baroni It feels weird that I only see elements for IOS and Android. My settings are for a PC application. Perhaps this is the cause in some way?
     
  46. scottlaforge

    scottlaforge

    Joined:
    Mar 12, 2013
    Posts:
    42
    I also switched platforms to Android, just to see if the errors would go away. I deleted everything and tried reimporting but still nothing.
     
  47. scottlaforge

    scottlaforge

    Joined:
    Mar 12, 2013
    Posts:
    42
    @Baroni All set. Problem resolved. I started a new project, loaded the Tanks Multiplayer, went through the setup, and now all good. Thanks for being so very responsive!
     
  48. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @scottlaforge Our asset should not be throwing any errors regardless of the platform (this is with the IAP plugin being imported into your project). If you start a new project, you probably didn't activate Unity IAP in the services panel yet? Clearly the UnityPurchasing files have been missing in your previous screenshot. Alternatively, you can also import Unity IAP from the Unity Asset Store here.
     
  49. scottlaforge

    scottlaforge

    Joined:
    Mar 12, 2013
    Posts:
    42
    @Baroni I re-looked at the initial project. I have not done any projects with In-App Purchasing or ads before. We simply do work for private industry clients. I had mistakenly turned on the Ads and not In-App Purchasing service. That's why it is now suddenly working.
     
    Baroni likes this.
  50. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Just a quick announcement regarding Photon Unity Networking integration. Go here for the original post & follow for more updates.

     
    scottlaforge likes this.