Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    Dismiss Notice

TANKS! Tutorial Q&A

Discussion in 'Community Learning & Teaching' started by willgoldstone, Sep 21, 2015.

  1. NTIGtelge

    NTIGtelge

    Joined:
    Mar 31, 2017
    Posts:
    1
    I'm trying to make a menu for the Tanks!-game. I can't get the UI work in this project though. I can't get the buttons respond. Is there some setting made to disable ordinary UI-functions? How do I do to make a menu for this project?
     
    Last edited: Apr 6, 2017
  2. Darky_lucera

    Darky_lucera

    Joined:
    Mar 24, 2015
    Posts:
    1
    Is there some patch to make the same 'trail particle' effect with the current unity version (5.6)?
     
    Last edited: Apr 13, 2017
  3. Thesam19

    Thesam19

    Joined:
    Feb 2, 2017
    Posts:
    1
    How to display the player name on a tank!! & how to display the result winner with player name!!
    I have taken 2 input fields to store the names in pref file
     
  4. olyvatwist

    olyvatwist

    Joined:
    Dec 8, 2015
    Posts:
    2
    Importing the tank asset into unity 5.5 give me redish color for the metalic models..
    Little help please.
    metal 2.PNG
    suppose to be gold

    metal.PNG
     
  5. olyvatwist

    olyvatwist

    Joined:
    Dec 8, 2015
    Posts:
    2
    Figured it out..
    By turning of reflections in the Forward Rendering Options in the Standard Shader.
     
  6. ix84gaming

    ix84gaming

    Joined:
    Apr 16, 2017
    Posts:
    2
    When I try to play the project, the tank will barely move. I have checked and Visual Studios says the code is fine. Can you help?
     
  7. Armouredgamer

    Armouredgamer

    Joined:
    May 2, 2017
    Posts:
    1
    Hi!
    I appreciate the tutorial, It's what I've been using in my programming class. I've been trying to add another player, which I can do, they spawn in, have an new spawn and color. If I end the round, they even pop up at the score screen!
    My only issue with player three, well, is that I'm unsure as to how to give them controls. If I could get some help, it'd be heavily appreciated! :)
     
  8. ix84gaming

    ix84gaming

    Joined:
    Apr 16, 2017
    Posts:
    2
    Go into the controls menu and add more controls
     
  9. thevinegru

    thevinegru

    Joined:
    Mar 24, 2017
    Posts:
    2
    I'm getting the exact same problem. The tutorial is using an LDR color picker and the color picker on that menu is HDR. I can't figure it out at all.
     
  10. thevinegru

    thevinegru

    Joined:
    Mar 24, 2017
    Posts:
    2
    Since updating to 5.6, this is the error I get.

    "Lighting data asset ‘LightingData’ is incompatible with the current Unity version. Please use Generate Lighting to rebuild the lighting data. Realtime Global Illumination cannot be used until the lighting data is rebuilt."

    Any suggestions?
     
  11. RobH99

    RobH99

    Joined:
    May 14, 2017
    Posts:
    5
    I finished the tutorial through Phase 7: Game Managers. I'm getting the following compile error:
    MissingComponentException: There is no 'AudioSource' attached to the "TankExplosion(Clone)" game object, but a script is trying to access it.
    You probably need to add a AudioSource to the game object "TankExplosion(Clone)". Or your script needs to check if the component is attached before using it.
    UnityEngine.AudioSource.Play () (at C:/buildslave/unity/build/artifacts/generated/common/modules/Audio/AudioBindings.gen.cs:610)
    TankHealth.OnDeath () (at Assets/Scripts/Tank/TankHealth.cs:66)
    TankHealth.TakeDamage (Single amount) (at Assets/Scripts/Tank/TankHealth.cs:46)
    ShellExplosion.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Scripts/Shell/ShellExplosion.cs:39)​

    My shells only explode when they hit a tank, not when they hit the ground or buildings.
    When the tank life is gone it doesn't end the game. I see the tank explosion, though.
    Please help!

    Thanks,
    Rob
     
  12. pabloestuardo0121

    pabloestuardo0121

    Joined:
    May 17, 2017
    Posts:
    1
    My tank does not lose health with the contact of the shell, here the script of TankHealth and shellexplosion

    please help!!.

    using UnityEngine;
    using UnityEngine.UI;

    public class TankHealth : MonoBehaviour
    {
    public float m_StartingHealth = 100f;
    public Slider m_Slider;
    public Image m_FillImage;
    public Color m_FullHealthColor = Color.green;
    public Color m_ZeroHealthColor = Color.red;
    public GameObject m_ExplosionPrefab;

    private AudioSource m_ExplosionAudio;
    private ParticleSystem m_ExplosionParticles;
    private float m_CurrentHealth;
    private bool m_Dead;


    private void Awake()
    {
    m_ExplosionParticles = Instantiate(m_ExplosionPrefab).GetComponent<ParticleSystem>();
    m_ExplosionAudio = m_ExplosionParticles.GetComponent<AudioSource>();

    m_ExplosionParticles.gameObject.SetActive(false);
    }


    private void OnEnable()
    {
    m_CurrentHealth = m_StartingHealth;
    m_Dead = false;

    SetHealthUI();
    }

    public void TakeDamage(float amount)
    {
    // Adjust the tank's current health, update the UI based on the new health and check whether or not the tank is dead.
    m_CurrentHealth -= amount;

    SetHealthUI();
    if(m_CurrentHealth <= 0f && !m_Dead)
    {
    OnDeath ();
    }
    }

    private void SetHealthUI()
    {
    // Adjust the value and colour of the slider.
    m_Slider.value = m_CurrentHealth;

    m_FillImage.color = Color.Lerp(m_ZeroHealthColor, m_FullHealthColor, m_CurrentHealth / m_StartingHealth);
    }


    private void OnDeath()
    {
    // Play the effects for the death of the tank and deactivate it.
    m_Dead = true;

    m_ExplosionParticles.transform.position = transform.position;
    m_ExplosionParticles.gameObject.SetActive (true);

    m_ExplosionParticles.Play();

    m_ExplosionAudio.Play();

    gameObject.SetActive (false);
    }
    }


    using UnityEngine;

    public class ShellExplosion : MonoBehaviour
    {
    public LayerMask m_TankMask;
    public ParticleSystem m_ExplosionParticles;
    public AudioSource m_ExplosionAudio;
    public float m_MaxDamage = 100f;
    public float m_ExplosionForce = 1000f;
    public float m_MaxLifeTime = 2f;
    public float m_ExplosionRadius = 5f;


    private void Start()
    {
    Destroy(gameObject, m_MaxLifeTime);
    }


    private void OnTriggerEnter(Collider other)
    {
    // Find all the tanks in an area around the shell and damage them.
    Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask);

    for (int i = 0; i < colliders.Length; i++)
    {
    Rigidbody targetRigidbody = colliders.GetComponent<Rigidbody>();

    if (!targetRigidbody)
    continue;

    targetRigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);
    TankHealth targetHealth = targetRigidbody.GetComponent<TankHealth>();

    if (!targetHealth)
    continue;

    float damage = CalculateDamage(targetRigidbody.position);
    targetHealth.TakeDamage(damage);
    }

    m_ExplosionParticles.transform.parent = null;
    m_ExplosionParticles.Play();
    m_ExplosionAudio.Play();
    Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.main.duration);
    Destroy(gameObject);
    }

    private float CalculateDamage(Vector3 targetPosition)
    {
    // Calculate the amount of damage a target should take based on it's position.
    Vector3 explosionToTarget = targetPosition - transform.position;
    float explosionDistance = explosionToTarget.magnitude;
    float relativeDistance = (m_ExplosionRadius - explosionDistance) / m_ExplosionRadius;
    float damage = relativeDistance * m_MaxDamage;
    damage = Mathf.Max(0f, damage);
    return 0f;
    }
    }
     
  13. RobH99

    RobH99

    Joined:
    May 14, 2017
    Posts:
    5
    Fixed: In the ShellExplosion script, when OnTriggerEnter is called, some code lines that belonged after the 'for' loop were inside it.
     
    Last edited: Jun 11, 2017
  14. RobH99

    RobH99

    Joined:
    May 14, 2017
    Posts:
    5
    ...and...
    Fixed! Like it said, I just had to add an Audio Source to the TankExplosion Prefab. I guess I just didn't make the connection that the Clone was the Prefab.
     
  15. smatsah

    smatsah

    Joined:
    Jun 6, 2017
    Posts:
    2
    Thank you guys first for this EPIC game..

    My game works fine so far. I have a question tho. In phase 6: after charging the tank will fire for sure. What i have noticed that in the tutorial, it fires 2 shells. Mine fires 1 shell only. Now, i do like my version, but I was wondering why does it fire twice in the tutorial??
    This is my code.
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3.  
    4. public class TankShooting : MonoBehaviour
    5. {
    6.     public int m_PlayerNumber = 1;    
    7.     public Rigidbody m_Shell;          
    8.     public Transform m_FireTransform;  
    9.     public Slider m_AimSlider;        
    10.     public AudioSource m_ShootingAudio;
    11.     public AudioClip m_ChargingClip;  
    12.     public AudioClip m_FireClip;      
    13.     public float m_MinLaunchForce = 15f;
    14.     public float m_MaxLaunchForce = 30f;
    15.     public float m_MaxChargeTime = 0.75f;
    16.  
    17.     private string m_FireButton;      
    18.     private float m_CurrentLaunchForce;
    19.     private float m_ChargeSpeed;      
    20.     private bool m_Fired;              
    21.  
    22.  
    23.     private void OnEnable()
    24.     {
    25.         m_CurrentLaunchForce = m_MinLaunchForce;
    26.         m_AimSlider.value = m_MinLaunchForce;
    27.     }
    28.  
    29.  
    30.     private void Start()
    31.     {
    32.         m_FireButton = "Fire" + m_PlayerNumber;
    33.  
    34.         m_ChargeSpeed = (m_MaxLaunchForce - m_MinLaunchForce) / m_MaxChargeTime;
    35.     }
    36.  
    37.  
    38.     private void Update()
    39.     {
    40.         // Track the current state of the fire button and make decisions based on the current launch force.
    41.         m_AimSlider.value = m_MinLaunchForce;
    42.  
    43.         if (m_CurrentLaunchForce >= m_MaxLaunchForce && !m_Fired)
    44.         {// max charge, not yet fired
    45.             m_CurrentLaunchForce = m_MaxLaunchForce;
    46.             Fire ();
    47.         }
    48.         else if (Input.GetButtonDown (m_FireButton))
    49.         {// fire the first time
    50.             m_Fired = false;
    51.             m_CurrentLaunchForce = m_MinLaunchForce;
    52.             m_ShootingAudio.clip = m_ChargingClip;
    53.             m_ShootingAudio.Play ();
    54.         }  
    55.         else if(Input.GetButton(m_FireButton) && !m_Fired)
    56.         {//holding the fire button, not yet fired
    57.             m_CurrentLaunchForce += m_ChargeSpeed * Time.deltaTime;
    58.             m_AimSlider.value = m_CurrentLaunchForce;
    59.         }
    60.         else if(Input.GetButtonUp(m_FireButton) && !m_Fired)
    61.         {//realesed, not yet fired
    62.             Fire();
    63.         }
    64.     }
    65.  
    66.  
    67.     private void Fire()
    68.     {
    69.         // Instantiate and launch the shell.
    70.         m_Fired = true;                                                                                        //Treat as Rigidbody
    71.         Rigidbody shellInstance = Instantiate (m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody;
    72.         //Launch the shell
    73.         shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward;
    74.         m_ShootingAudio.clip = m_FireClip;
    75.         m_ShootingAudio.Play ();
    76.         m_CurrentLaunchForce = m_MinLaunchForce;
    77.     }
    78. }
     
  16. twilightZone

    twilightZone

    Joined:
    Oct 10, 2014
    Posts:
    27
    Hello all,
    I have a very stupid question in the Assets folder, we have a file "Readme.asset". When we look this file in the inspector, it contains some text, a picture and two links. Can you explain how you have created this special readme.
    Thanks a lot
     

    Attached Files:

    megabrobro likes this.
  17. megabrobro

    megabrobro

    Joined:
    Jul 8, 2017
    Posts:
    22
    Hi, im just moving over to Unity3d from working in code only with XNA and LibGDX. Unity looks brilliant but very different from how I'm used to working.

    I'm having trouble following the Tanks Tutorial. I have the assets loaded into my project and can follow along, but i don't understand how and when to make the folders myself. I was hoping to learn how to create the game from scratch and importing all the assets as part of the tutorial.

    Is there any other current updated tutorial for unity 5.6 that will cover importing all assets from scratch. I've worked on the RollABall tutorial but this is only using primitives. I'd like to learn next about attaching a texture to the plain. Adding 3d models made in 3rdParty software and adding textures to those models.
     
  18. ukmadorian

    ukmadorian

    Joined:
    Jul 16, 2017
    Posts:
    1
    I have a annoying problem in part 7 to 8.

    When I drag the CameraRig to the CameraControl public object of the GameController it doesn't filled, just continue as "CameraControl(none)" in light gray.

    Can you help me please?
     
  19. caomaru

    caomaru

    Joined:
    Jul 22, 2017
    Posts:
    1
    Hello! I'm making this project for my investigation project at college, and I have a little problem with tutorial nº2. My problem is that I can move the audio and the particles but not the tank, I've revised the tutorial's code like 10 times and idk if it's a code problem or a collision problem or smthng like that. Can anyone help me? Thank you all guys!
     
  20. Dickson2305

    Dickson2305

    Joined:
    Jul 24, 2017
    Posts:
    1
    Hello,
    I've just finished all 8 parts of the tutorial and was wondering how I would go about expanding the game by adding level select and character select, this would be on offline 2 player. I'm fairly new to unity and would like a bit of direction on how to implement this. I want to be able to choose a level, then player 1 & 2 choose there colours?
    Cheers in advance
     
  21. Cool_Gamer_SKJ_007

    Cool_Gamer_SKJ_007

    Joined:
    May 31, 2017
    Posts:
    5
    Hey, could you pass me copy of the .exe file for Windows PC 32-bit (x86). I really want to try out the mods.

    P.s. I could be your Beta tester if you like. I could debug and collect error reports for you to help straighten your project.
     
  22. bhushan629

    bhushan629

    Joined:
    Aug 29, 2017
    Posts:
    1
    Hello,

    I am using Unity version 2017.1. In Tanks Video Tutorial : 01 Scene Setup, they are doing some ligh baking configuration. but i didn't found those setting in new unity version. so anyone know how to setup lighting setting in unity 2017.1
     
  23. Lord_Scelettron

    Lord_Scelettron

    Joined:
    Sep 2, 2017
    Posts:
    2
    hi,
    i am on unity 2017.1.0f3 and the game manager and the shell explosion scripts does not work could someone give me updated scripts ???
     
  24. Lord_Scelettron

    Lord_Scelettron

    Joined:
    Sep 2, 2017
    Posts:
    2
    when you disable autau lighting the bake button is to the right of it
    I hope that helps you bhushan629
     
  25. jortd

    jortd

    Joined:
    Jul 17, 2017
    Posts:
    3
    I know this is 2 years old by now, but my tank is moving on its own. It's also rotating and I don't know why this happens...
    Can any1 help me?

    Thanks :D
     
  26. jortd

    jortd

    Joined:
    Jul 17, 2017
    Posts:
    3
    Go to Edit>Project Settings>Input

    Set the axis up from 16 to 18

    Name the last two:

    Horizontal3
    Vertical3

    Give a positive button(horizontal means forward, vertical means right)
    Give a negative button(horizontal means backwards, vertical means left)

    Set the gravity to 3
    Dead to 0.001
    Sensitivity to 3

    Snap:eek:n
    Invert:eek:ff

    Type: key or mouse button
    X-Axis
    Get Motion from all joysticks

    Do this for both fields, Horizontal and vertical

    Hope this helps!
    Cheers
     
  27. jortd

    jortd

    Joined:
    Jul 17, 2017
    Posts:
    3
    The scripts still work, maybe try the lesson again?
     
  28. jsteph67

    jsteph67

    Joined:
    Sep 18, 2014
    Posts:
    1
    Question AddExplosionForce, it appears to continues to apply force to my tanks. If I drop the completedTank it works right. But if I am doing it as we go, the tank flies across the screen. When I moved the tank and stop moving it will start moving in the direction of the force. The weird part is, I copy all of the components from the completedTank to the new tank and it is still doing it:
    https://gfycat.com/gifs/detail/RemoteFriendlyFruitbat

    I dropped one of their tanks in and copied all of the same components that same issue. So I am not sure what I am missing.
     
  29. Eliasnd

    Eliasnd

    Joined:
    Nov 14, 2017
    Posts:
    3
    I've downloaded the project and opened it, but there's no Scenes folder and Unity crashes when I try to add the LevelArt prefab.
     
  30. Smart-hawk1

    Smart-hawk1

    Joined:
    May 23, 2017
    Posts:
    37
    Just starting out this project, how hard would it be to make it a split screen and a 3rd person view ?