Search Unity

Tanks!!! Reference Project, for Unity Multiplayer Q&A

Discussion in 'Community Learning & Teaching' started by richard-lee, Feb 17, 2017.

  1. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    18
    Hi LLRx

    As mentioned previously, Tanks!!! was not built with localisation in mind. But let me help you with the last batches of translations :). For shooting range UI and Settings UI, edit the following prefabs under UI:
    * ShootingRangeModal
    * ShootingRangeStartGameModal
    * Settings

    For the buttons in the ServerList and Lobby this text is changed in code. The easiest way to change this is to search the entire solution for the string literals and change them. I hope this helps :)
     
  2. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    18
    Hi fnaveedshah

    I tested out the method I sent you and I am not seeing that issue. If you could send me the full editor log (console) then I'd be happy to look at it for you :)
     
  3. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    18
    Hi iTzRixerGG

    Please refer to my response to @fnaveedshah where I describe this process :).
     
  4. AlecLarsen1989

    AlecLarsen1989

    Joined:
    Feb 7, 2017
    Posts:
    18
    Hi alexdion

    We have solved this issue in the Tanks!!! project, given in the first post on this forum :). The above code looks like an excerpt from the old Tanks networking project. The delay you are seeing is network delay (ping). It's basically there because the server is creating the projectile and causing the client to do the same. Check out our solution in the new Tanks!!! project :)
     
  5. miterrooter

    miterrooter

    Joined:
    Oct 4, 2016
    Posts:
    3
    Sorry about bumping my own post up I just wanted to add these tags for @richard-lee & @AlecLarsen1989 . I am not too familiar to posting in the forums so im not sure if this is necessary. I think my question is best targeted at you two so if you could find the time to explain how to get to a solution(or if im going in the entirely wrong direction) I would greatly appreciate the help. Alternatively the document mentioned in previous posts seems like it would be a great guide.
     
  6. richard-lee

    richard-lee

    Unity Technologies

    Joined:
    Jul 14, 2015
    Posts:
    50
    My mistake all. The package will be updated with the document. For now, it is attached to this post.
     

    Attached Files:

  7. miterrooter

    miterrooter

    Joined:
    Oct 4, 2016
    Posts:
    3
    Thanks @richard-lee the document is a good introduction of how the code is structured. It helps before going to reverse engineer the code. I have still run into difficulty if anyone can help. I have decided to try to add a local host feature for testing reasons. What I am trying is to add a button to the create game panel and from that button create a local host lobby. This has only worked so far as to create a lobby entry for the player but the ready button is not enabled. I would just like to know am i going about this the right way and if there are any tips to solve this.
     
  8. eDorosh

    eDorosh

    Joined:
    Aug 20, 2016
    Posts:
    1
    Hi. I'm developing my own project with UNet (4 person multiplayer) and have one very nasty issue with collapsing app on host (on mobile). I downloaded "Tanks!!!" to learn it, and found thing that :
    - If I get and run build that downloaded from AppStore, play it, and the host collapse his app -> it (host) has at least 2-3 seconds to maximize app and save current match without "server disconnected";
    - however If I create my own build of Tanks!!! (I change nothing, only make build), run it on mobile and host is collapsing -> other participants get "server disconnected" immediately!
    Why?
     
  9. richard-lee

    richard-lee

    Unity Technologies

    Joined:
    Jul 14, 2015
    Posts:
    50
    eDorosh. Couple of scenarios come to mind.

    - Difference in version. The version on the app store was built on, if I recall correctly, 5.4.
    - Didn't setup Multiplayer. You said you didn't make any changes to the app. At minimum, if you're taking the project and build locally, so you setup your Multiplayer settings. This is in the documentation (Section 2.1)
     
  10. fnaveedshah

    fnaveedshah

    Joined:
    Dec 15, 2013
    Posts:
    6
    Sir ty for looking at this problem, i hope you are fine
    sir i tried to put new tanks as you mentioned , but these tanks cant be purchased in shop,
    lot of people have same problem , so if you kindly make a tutorial for simply add new tank that can be purchase-able in shop
    Iam working on this project from months and i stuck here i hope you can help me
     
  11. Luke-Lamothe

    Luke-Lamothe

    Joined:
    Feb 6, 2013
    Posts:
    22
    @fnaveedshah, @AlecLarsen1989 responded to you previously above and said that if you are able to send him your full console log, he may be able to help you track down what is breaking on your side, so if possible, you should probably take him up on his offer :)
     
  12. fnaveedshah

    fnaveedshah

    Joined:
    Dec 15, 2013
    Posts:
    6
    @
    Luke-Lamothe actually i give up , worst support experience in unity , moving to unreal engine
     
  13. theferfactor

    theferfactor

    Joined:
    Dec 16, 2016
    Posts:
    2
    Thank you very much for this reference project, it's really amazing.
    I have just one question
    How can I make a local LAN multiplayer out of this?
     
    frank28 likes this.
  14. sajjad2000

    sajjad2000

    Joined:
    Jul 6, 2017
    Posts:
    2
    Hi.I recently imported Tanks reference project from asset store to a new project without any changing or deleting or adding anything.when i want to build it for android,it shows me this error:unable to convert classes into Dex format! I Know that i must delete duplicate files but i still cant build it!!!!! Ok,If my project and their project is the same,so how they published it for android in google play?
     
  15. Tomahawkppc

    Tomahawkppc

    Joined:
    Jul 31, 2012
    Posts:
    8
    Hi, has anyone tried to integrate a password for a private lobby? Cheers!
     
  16. VREntertainment

    VREntertainment

    Joined:
    Aug 22, 2015
    Posts:
    15
  17. orkungo

    orkungo

    Joined:
    May 3, 2014
    Posts:
    61
    Hi,

    I am trying to bundle the scenes to the AssetBundles, download them to the Application.persistentDataPath and load relevant scene at the Network Manager.

    Network Manager loads the game scene by ServerChangeScene(map.name);

    However, I need one previous step to load scene from asset bundle and progress to the scene, something like following:

    string scenePath = myLoadedAssetBundle.GetAllScenePaths()[0];
    SceneManager.LoadScene(scenePath);

    When I follow above steps with AssetBundles and use them at the NetworkManager, since I do not load my scene using ServerChangeScene method, I can not follow next steps of Networking and can not load the CompleteTank.

    Any ideas to help?
     
    Last edited: Oct 20, 2017
  18. JohnyDaison

    JohnyDaison

    Joined:
    Jul 27, 2017
    Posts:
    1
    Hi,
    I imported this project into Unity 2017.2.0f3 and everything works, but the tanks have shorter firing range. I checked the Physics settings and everything seems to be set up according to the PDF. Everything else seems ok, comparing with the youtube video, but the projectiles just don't fly as far as they should. I didn't make any changes except multiplayer setup before building the game. Anyone has any idea how is this possible?
     
    csivek likes this.
  19. GoRiLLa

    GoRiLLa

    Joined:
    Oct 8, 2013
    Posts:
    14
    I have the same issue, making it impossible to complete first Training mission.

    Even worse, I am not able to create any multiplayer games as it immediately fails upon creating game.
     
  20. FrancoFresco

    FrancoFresco

    Joined:
    Aug 1, 2012
    Posts:
    2
    Thanks for this reference project! it's actually a lot of fun! Shooting works fine for me (playing in the editor, 2017.2)

    Like GoRiLLa, I too am experiencing failing at creating a game.

    In editor
    - open splashScreen scene
    - click through then click Create Game
    - Give a server name and hit start
    - See prompt, "Failed to create game"

    Checked log and I'm not seeing any error messages.

    I did have to update the APIs to complete the import from the Asset store.
    I'm thinking has to do with this. I'm very new to UNet, so not exactly sure where to look to fix it.

    I'd love to learn from this.

    Thank you!
     
  21. FrancoFresco

    FrancoFresco

    Joined:
    Aug 1, 2012
    Posts:
    2
    In CreateGame.cs

    private void StartMatchmakingGame()
    {
    m_NetManager.StartMatchmakingGame(GetGameName(), (success, matchInfo) =>
    { ... });
    }

    It's definitely failing here.

    Where is "matchInfo" declared? I'm not even sure how this compiles..

    Thanks!
     
  22. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    @JohnyDaison @GoRiLLa @FrancoFresco

    Failed to Create Game
    If you're getting "Failed To Create Game" whenever you try to start a multiplayer match it's most likely because you haven't setup the Unity multiplayer service correctly or at all. Please read the "TanksReference" PDF file included in the root of the project for information on how to do this.

    Projectile Firing Issue
    Fired shells are supposed to land wherever you click/tap on the screen, but this is no longer the case in Unity 2017.2. After checking out what's new I noticed that they added a new physics related feature:
    I immediately suspected that this was the cause of the issue, however, messing with these new settings seemed to have no effect, so I scoured the source code and finally found the culprit in Shell.cs, line 135:

    Code (CSharp):
    1. // Face towards our movement direction
    2. private void Update()
    3. {
    4.     m_Transform.forward = m_CachedRigidBody.velocity;
    5.  
    6.    // Spin the projectile
    7.    m_CurrentSpinRot += m_Spin * Time.deltaTime * m_CachedRigidBody.velocity.magnitude;
    8.     m_Transform.Rotate(Vector3.forward, m_CurrentSpinRot, Space.Self);
    9.  
    10.    // Enforce minimum y, in case we go out of bounds
    11.    if (m_Transform.position.y <= m_MinY)
    12.    {
    13.        Destroy(gameObject);
    14.    }
    15.    else
    16.    {
    17.        // Reset this. We can set it to true during bounces to stop multiple colliders hitting it per frame
    18.        m_Exploded = false;
    19.    }
    20. }
    You simply need to move this snippet of code from Update() to FixedUpdate() and projectiles will land in the intended location once again. Hooray!

    Apparently this new physics feature has an adverse effect on any modifications made to the transform outside of FixedUpdate.

    Happy coding!

    @richard-lee @AlecLarsen1989 this projectile bug should really get an official patch ASAP because as GoRiLLa has pointed out already, it makes completing the first training mission nearly impossible and I'm sure this will cause a lot of support requests and confusion if not addressed soon.
     
    Last edited: Dec 12, 2017
    ibyte and Le_Tai like this.
  23. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    928
  24. cj31387

    cj31387

    Joined:
    May 23, 2012
    Posts:
    141
    Is this project fully authoritative ?
     
  25. Ghost004

    Ghost004

    Joined:
    Jan 27, 2016
    Posts:
    3
    Hello, I'm trying to add a tank (followed the post above and added tank to library)is there something else I need to do?

    Unity version 2017.3.1f1
    fresh project and tanks import

    getting index out of range error when I try and purchase.
    upload_2018-3-21_20-18-37.png
     
    Last edited: Mar 28, 2018
  26. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    @Ghost004 @fnaveedshah @wioluskaelk

    IndexOutOfRangeException: Tank index is invalid
    Hi @Ghost004, think I found the cause of this. It's a very tricky and somewhat dishonest bug, so past advise was not actually correct. The error appears to be caused by loading old save data that doesn't account for the increased number of tanks.

    The easiest solution I've come up with for this is to not load any save data the first time you enter play mode after changing something. New save data will then be automatically created once you exit play mode, overwriting the old data and updating the tank count. You can then start loading saved data again as long as you don't change anything.

    I did this in the project by simply adding a m_LoadSavedData boolean at the top of the PlayerDataManager class. Then I simply check if this variable is true before loading any data on line 145. So I can now just uncheck this option in the editor before entering play mode when I want to overwrite and update the save data.

    load_saved_data_option.png

    This will of course also erase all earned currency. So for testing I also created a Cheats script and attached it to the PlayerData game object with this code inside so I can test unlocking tanks.

    Code (CSharp):
    1. using Tanks.Data;
    2. using UnityEngine;
    3.  
    4. public class Cheats : MonoBehaviour
    5. {
    6.     void Update () {
    7.  
    8.         if (Input.GetKeyDown(KeyCode.M))
    9.             PlayerDataManager.s_Instance.AddCurrency (100);
    10.     }
    11. }
    A better way to do this would be to create a game version string variable. Then overwrite old save data every time this string value changes (e.g. "1.0" to "1.1"). This way it works for both editor and player builds so players will not get errors if you update your game and they load incompatible save data. However, implementing this requires more work. So I'm just sharing my simple solution here.
     

    Attached Files:

    zt3ff3n likes this.
  27. zt3ff3n

    zt3ff3n

    Joined:
    Feb 19, 2016
    Posts:
    17
    Thanks for posting these updates and fixed @IsaiahKelly, I just started my first project - using this template to learn from, and I'm not too smart with code o_O.

    However, your previous post regarding the Projectile Firing Issues, and the proposed fix of replacing
    Code (csharp):
    1. private void Update()
    to
    Code (CSharp):
    1. [CODE]private void FixedUpdate()
    [/code] gives me an error.

    Assets/Scripts/Shell/Shell.cs(128,16): error CS0111: A member `Tanks.Shells.Shell.FixedUpdate()' is already defined. Rename this member or use different parameter types

    // Nevermind.
    I misunderstood you, and renamed that the update function. *Moving* its content to the above fixedupdate function does indeed work!
     
    Last edited: Apr 24, 2018
  28. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    @zt3ff3n Glad you found it helpful :). Yes, FixedUpdate is already defined in the script and you can only define that type of method once per script. So you need to move the code over instead of just renaming the method.

    You could also just rename the update method to something else completely like "ProjectileUpdate" and then call that from inside the FixedUpdate method instead. In fact, doing so is usually recommended because it allows you to easily move code execution around later if you need to.

    Best of luck with your project!
     
    Last edited: May 2, 2018
  29. zt3ff3n

    zt3ff3n

    Joined:
    Feb 19, 2016
    Posts:
    17
    I'm trying to access the value for the tanks health, but so far not having any luck.
    Though I'm a pretty poor programmer, according to tons of googling, this should work - however it only outputs "health: 0 / opacity 1" in the debug. I attach this script to a world object I want to change the materials alpha value of according to the players health..

    - I can't even seem to find the code where the magic for the healthbar-circle is located to have a look at that. A push in the right direction would be pretty welcome!


    Code (CSharp):
    1.  
    2. using System;
    3. using UnityEngine;
    4. using UnityEngine.Networking;
    5. using Tanks.Map;
    6. using Tanks.Explosions;
    7. using Tanks.Data;
    8.  
    9. namespace Tanks.TankControllers
    10. {
    11. public class MatScript2 : MonoBehaviour {
    12. //private float tanksHealth;
    13. private float healthOpacity;
    14.   void Start()
    15.     {
    16.  
    17.   float tanksHealth = GameObject.Find("CompleteTank").GetComponent<TankHealth>().m_CurrentHealth;
    18.   float healthOpacity = ((100 - tanksHealth) / 100);
    19.  
    20.        Debug.Log("Hello TANK");
    21.        Debug.Log("health: " + tanksHealth);
    22.        Debug.Log("opacity: " + healthOpacity);
    23.      }
    24.     void Update ()
    25.       {
    26.  
    27.     gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", healthOpacity);
    28.       }
    29.  
    30.  
    31.   }
    32. }
    33.  
    34.  
     
  30. Reshad

    Reshad

    Joined:
    Mar 23, 2013
    Posts:
    5
    Hi, I want to change this game for 2 players only. I don't want to create and join. I want to connect directly and go to game scene like clash royale. Is this possible? If so how??
     
  31. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    @zt3ff3n Sorry for the late reply. Haven't checked this tread for some time.

    First off, using GameObject.Find is generally a bad idea because there's way too much room for error. For example, your code will only find game objects with the exact name "CompleteTank", but since all tank prefabs are instantiated at runtime, the name will actually be something like "CompleteTank(clone)2", so this will never find it!

    A better choice would be to use FindObjectOfType instead, which finds the actual component itself, regardless of game object name:

    Code (CSharp):
    1. float tanksHealth = FindObjectOfType<TankHealth> ().m_CurrentHealth;
    However, this code will only return the very first instance of TankHealth it finds, and since this is a multiplayer game, that might not be the one you want. You could use FindObjectsOfType instead, which returns an array of all active TankHealth components, but this still doesn't help you figure out which one you actually want.

    In any case, trying to find the health component from another object is probably not the best way to go about this because it's very likely to break and lead to issues if you ever change or expand things in your game. So it's probably much better to have something on the tank prefab itself handling this.

    The health bar element is controlled by the HUDCanvas prefab found in the Prefabs/UI folder. It has a script attached to it called HUDController that communicates with the GameManager to subscribe to tank health change events, so it can update the UI display. Examining these scripts should hopefully help guide you in the right direction to get your game mechanic working.
     
    Last edited: Nov 20, 2018
  32. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    Anything is possible, it's just a matter of how much work is required. To change max players go to the NetworkManager component and change "Multiplayer Max Players" to 2.

    You will then need to modify or replace the LobbyPanel component if you want to eliminate the lobby system all together, but that is far too broad a subject to answer here. I would suggest reading the manual and checking out the Simple Multiplayer Example for help doing this.
     
    Last edited: May 26, 2018
  33. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    @newbeep You'll want to open the script named SinglePlayerCompleteModal and go to about line 139 where you should see this:

    Code (CSharp):
    1.  
    2. if (!success)
    3. {
    4.    achievementObject.SetToFailedState();
    5.    Vector2 newPanelSize = m_MainPanel.sizeDelta;
    6.    newPanelSize.y = m_FailedPanelHeight;
    7.    m_MainPanel.sizeDelta = newPanelSize;
    8.    break;
    9. }
    10. if (success && objective.lockState == LockState.NewlyUnlocked)
    11. {
    12.    m_AchievementsToPlay.Add(achievementObject);
    13.    achievementObject.SetUpCurrencyReward(objective.currencyReward, m_CurrencyAmountDisplay, currentCurrency);
    14.    currentCurrency += objective.currencyReward;
    15. }
    16. else if (objective.lockState == LockState.PreviouslyUnlocked)
    17. {
    18.    achievementObject.AlreadyAchieved();
    19.    achievementObject.animator.Play(m_AchievedAnimationName);
    20. }
    21. else
    22. {
    23.    achievementObject.SetCurrencyRewardText(objective.currencyReward);
    24. }
    25.  
    The LockState check and SetUpCurrencyReward method is key here. You can simply remove the LockState check from the if condition and the followup else statements to let the player get rewarded every time they complete an objective.
     
  34. SharkTeam

    SharkTeam

    Joined:
    Jan 28, 2016
    Posts:
    7
    Hello everyone,

    Can someone help me which scripts should I remove in order to be left only with a working lobby scene (Create Match, Find Match, choosing player, settings, quit)? Also I would like to be able to choose maps and game modes etc, I just wanna remove all the gameplay scripts...I'm planing on using a bit different gameplay so this gameplay is not an option, but lobby system is build really well so.. :)

    Thank you in advance!
     
  35. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    @SharkTeam If you're mostly interested in the lobby system itself then it would probably be easiest to just use the Network Lobby example instead and modify it to your needs.

    However, if you want to use the game mode and map selection logic from this project it will require a bit of work since it's directly connected to the gameplay logic. So you'll first need to study the code to understand what exactly you want/need to strip out. e.g. do you want to keep cosmetics, damage, projectiles, etc. ?

    Most of the gameplay specific logic is located in the Scripts sub-folders "Tank", "Shell", "Rules", and "Powerups". So those are good places to start, but this will not be a super simple modification! So I would also highly recommend using some kind of version control system (e.g. Unity Collaborate) if you decided to try and modify the project. That way you can easily undo any change that breaks the project entirely.
     
  36. SharkTeam

    SharkTeam

    Joined:
    Jan 28, 2016
    Posts:
    7
    Thank you for a fast reply!

    Yes im aware that it wont be a simple modification.
    Unity Collaboration is actually a great advice thank you for that.
    My plan is to remove the way tank moves, fires etc and scripts for decorations and tank stats, but i want to keep a game mode and map logic as you said.
    I will start with subfolders that you mentioned and see where it will lead me.
    I just wanted to know where is the specific gameplay logic mostly located so thanks :)
    My plan is to have a third person character so thats why that part of gameplay is not necessary for me
     
  37. And1love

    And1love

    Joined:
    May 23, 2018
    Posts:
    2





    Hello) I`m new in unity. But... if you want something like cool down or delay you must ADD some new variables like TimeBetwShots, or make it with IEnumerator. I`ve learn much from "CooldownTutorials" and i have made a cooldown Buttons with nice Effect. look for this man "BlackThornProd" in youtube, he simply teached you about delay in shoots.
     
  38. RuslanBekniyazov

    RuslanBekniyazov

    Joined:
    Jun 29, 2018
    Posts:
    1
    Hi, is that okay if I use some parts of this project for my project that I plan to release (music for example)?
     
  39. TygoW

    TygoW

    Joined:
    Nov 20, 2017
    Posts:
    1
    Hello, how do i add a tank i have added a tank to the tank library but it still gives the error "Tank index invalid".
    can someone please help?

    it only works when i delete an other tank i can only have 3 tanks
     
    Last edited: Aug 20, 2018
  40. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    Read the LICENSE.TXT file that comes with the project for information on how you can use it. If an asset doesn't include a license file then it's usage is governed soley by the Asset Store Terms of Service. Take a look at the "END-USER's Rights and Obligations" section in that document.

    This issue is caused from loading old saved data. Read post #76 for a solution to this very issue.

    Modifying the FireTransform alone wont do anything. You need to modify the TankShooting script which controls the shooting behavior. However, this could be complicated because the system uses both a client-side visual "fake" bullet and server-side "real" bullet. So you need to modify both types at once. There's also a "cluster bomb" power-up that does create multiple shots already, but only after impact.
     
  41. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    Very true! That's why I wouldn't recommend diving into the topic if it's your first project. Networking will make your project 10x more complicated. The networking in this demo is also now outdated and Unity is currently creating a replacement (see FPS Sample). So I'd strongly recommend starting with the Survival Shooter, Tower Defense, or 3D gamekit examples instead.

    However, if you still want to pursue this, you can learn more about how networked projectiles work in the TanksReference.pdf file that comes with the project. Checkout page 15, Section 5 - Networking.

    The actual code you'll probably want to modify is in the Fire method in TankShooting script, near line 424:
    Code (CSharp):
    1.             // Immediately fire shell on client - this provides players with the necessary feedback they want
    2.             FireVisualClientShell(fireVector, m_FireTransform.position, randSeed);
    3.  
    4.             CmdFire(fireVector, m_FireTransform.position, randSeed);
    You could, for example, duplicate both of these lines and give them a different fireVector and/or m_FireTransform.position to create extra bullets.

    One quick way to support the use of multiple fire transforms would be to change the m_FireTransform variable on line 32 into an array by adding [ ] to the type definition.

    So this...
    Code (CSharp):
    1. private Transform m_FireTransform;
    ...becomes this:
    Code (CSharp):
    1. private Transform[] m_FireTransform;
    Then you need to update the Fire method to handle the new array, like this:
    Code (CSharp):
    1.  
    2.        private void Fire()
    3.        {
    4.            // Set the fired flag so only Fire is only called once.
    5.            m_Fired = true;
    6.  
    7.            //Determine which shell we should fire.
    8.            Shell shellToFire = GetShellType().GetComponent<Shell>();
    9.  
    10.            // Get a random seed to associate with projectile on all clients.
    11.            // This is specifically used for the cluster bomb and any debris spawns, to ensure that their
    12.            // random velocities are identical
    13.            int randSeed = UnityEngine.Random.Range(int.MinValue, int.MaxValue);
    14.  
    15.             Vector3 fireVector = new Vector3();
    16.  
    17.             for (int i = 0; i < m_FireTransform.Length; i++)
    18.             {
    19.                 //Determine our firing solution based on our target location and power.
    20.                 fireVector = FiringLogic.CalculateFireVector(shellToFire, m_TargetFirePosition, m_FireTransform[i].position, m_CurrentLaunchAngle);
    21.  
    22.                 // Immediately fire shell on client - this provides players with the necessary feedback they want
    23.                 FireVisualClientShell(fireVector, m_FireTransform[i].position, randSeed);
    24.  
    25.                 CmdFire(fireVector, m_FireTransform[i].position, randSeed);
    26.             }
    27.  
    28.            // Reset the launch force.  This is a precaution in case of missing button events.
    29.            m_CurrentLaunchAngle = m_MaxLaunchAngle;
    30.  
    31.            m_ReloadTime = m_RefireRate;
    32.  
    33.            // Small screenshake on client
    34.            if (ScreenShakeController.s_InstanceExists)
    35.            {
    36.                ScreenShakeController shaker = ScreenShakeController.s_Instance;
    37.  
    38.                float chargeAmount = Mathf.InverseLerp(m_MaxLaunchAngle, m_MinLaunchAngle, m_CurrentLaunchAngle);
    39.                float magnitude = Mathf.Lerp(m_ShootShakeMinMagnitude, m_ShootShakeMaxMagnitude, chargeAmount);
    40.                // Scale magnitude
    41.                shaker.DoShake(m_TargetFirePosition, magnitude, m_ShootShakeDuration);
    42.            }
    43.  
    44.            m_RecoilTime = 1;
    45.            Vector3 localVector = transform.InverseTransformVector(fireVector);
    46.            m_RecoilDirection = new Vector2(-localVector.x, -localVector.z);
    47.        }
    48.  
    You will also need to update all other variables related to the m_FireTransform by making them arrays too (adding [ ] to each). Check the console for errors since this will let you know which ones need updating.

    Then finally reassign the fire transform(s) on the TankDisplay script attached to each tank prefab found in the Prefabs/Tanks/Types folder. Your tanks will now automatically fire a bullet from each transform assigned to the m_FireTransform array.
     
    Last edited: Nov 20, 2018
  42. ishwara_bhat

    ishwara_bhat

    Joined:
    Oct 18, 2018
    Posts:
    11
    Hi,
    I am trying to run the game for the first time. When I try creating the game, it simply gives error - "Failed to create game".
    I have created Unity project in 2017.2 and imported after adding it in asset.

    Please suggest what could be wrong. Does it involve any app key / account setup before running it?

    Thanks in advance.
     

    Attached Files:

  43. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    @ishwara_bhat you most likely didn't setup the multiplayer service yet. To do so open the Services window by pressing control + 0 or by going to Windows > Services from the toolbar. Then enable services and make sure multiplayer is on. To do this I think you need to go to your dashboard and set room size:

    unity_multiplayer_room_size.png

    Checkout the TanksReference.pdf file that came with the project for more details.
     
    Last edited: Jan 20, 2019
    ishwara_bhat likes this.
  44. ishwara_bhat

    ishwara_bhat

    Joined:
    Oct 18, 2018
    Posts:
    11
    Thanks a lot ! You were right. I had not set it up. Thanks for the help.
     
  45. omnedeus_unity

    omnedeus_unity

    Joined:
    Apr 3, 2019
    Posts:
    2
    I have the exact same problem as this user, (who posted years ago).

    Is there a solution? Only have this issue with the multiplayer. I've properly setup the multiplayer, and can get players to join the servers; it's just won't get past the MessageCanvas --> WaitingModal.

    To reproduce, just download the package and setup multiplayer. Build for android, (legacy depreciated build + unsigned Alias Key). The game builds, and I can setup servers on pc unity & android. When the server starts, it gets hung up on the waiting modal permanently. Singleplayers modal works fine, and will allow u to play the game.

    Single player, and all other functionality works fine, even in 2019 and the 2018.3.0f2 build of unity.

    I decided on building my vuforia mixed reality applications from scratch using a new package. The TANKS!!! asset seemed perfect. If I can get this error fixed, I can show off some cool immersion-games which used networked cameras.
     
    JOSEPMP likes this.
  46. omnedeus_unity

    omnedeus_unity

    Joined:
    Apr 3, 2019
    Posts:
    2
    I guess this project, like all the other projects on the assets store is abandonware.

    Time to start from scratch from another asset again...

    If I had to guess, it's because you use UNet framework for your networking, which is being phased out to force poor devs like myself to shell out money for the other "paid" versions.

    As a developer, we NEED free assets to rapidly prototype builds, and we CANT shell out hundreds of dollars on faulty software. I missed a really important opportunity where 100 people were waiting to see my application.
     
  47. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    @JOSEPMP What exactly are the warning messages? I opened this project in Unity 2019.1.1f1 and setup Android according to the official instructions and it worked just fine. However, I had to remove the Everyplay plugin completely to get it to successfully build. This is something you should do regardless because support for Everyplay has been discontinued. So if you still have this plugin in the project it may be causing issues since it's supposed to run at the start of each game.

    cc: @omnedeus_unity
     
  48. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    Not familiar with AdMob but you can use the AddCurrency() method found in the PlayerDataManager script to modify the value. So try adding this to the end of your reward method:

    Code (CSharp):
    1. PlayerDataManager.s_Instance.AddCurrency(amount);
     
  49. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    Impossible to know without more info but what do you mean by "leaving the game"? You mean ending the match or just walking away for a bit? The score should actually be reset between matches but maybe you mean coins gained? If it's the latter case then you need to find out what's resetting your DataStore currency value.
     
  50. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    334
    The AddCurrency() method automatically saves the new value so I'm not sure how that's possible.

    I tested adding currency during a single-player mission with my cheats script and it worked just fine. So I can only guess that you must be resetting the currency value somewhere or calling the AdMob function at the wrong time.