Search Unity

Official TANKS! Tutorial Q&A

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

  1. McPeppergames

    McPeppergames

    Joined:
    Feb 15, 2019
    Posts:
    103
    Can this be imported to Unity 2020 (alpha) ? It doesn't seem to get loaded and I can not click on the important assets in the list to select them when being asked what should be imported. Any help?
     
  2. ethanzfurman

    ethanzfurman

    Joined:
    Mar 12, 2020
    Posts:
    5
    Hello. I am really enjoying the tanks tutorial, but I am still having trouble attaching the TankMovement script to my Tank Prefab. I can't add the empty or the completed script. Both times, I end up with an error that says, "Can't add script behaviour CallbackExecutor. The script needs to derive from MonoBehaviour!" I have no idea what this means, but I'm hoping somebody else does. I'm using this on Unity 2018.4.18f1. Does anybody know a fix for this?

    error.PNG

    Oh yeah, I am also getting these console errors:
    console errors.PNG
     
    Last edited: Mar 13, 2020
  3. Roulik

    Roulik

    Joined:
    Jan 15, 2018
    Posts:
    14
    Check if your script has :MonoBehaviour after public class CallbackExecutor
     
  4. ethanzfurman

    ethanzfurman

    Joined:
    Mar 12, 2020
    Posts:
    5
    Yup, I got that code.PNG
     
  5. Roulik

    Roulik

    Joined:
    Jan 15, 2018
    Posts:
    14
    I can said almost sure de last two errors you have is because your tank don't have rigidbody component, still i don't know why you can't add the script to tank
     
  6. Roulik

    Roulik

    Joined:
    Jan 15, 2018
    Posts:
    14
    Could put image of inspector tab with your tank prefab selected?
     
  7. ethanzfurman

    ethanzfurman

    Joined:
    Mar 12, 2020
    Posts:
    5
  8. Roulik

    Roulik

    Joined:
    Jan 15, 2018
    Posts:
    14
    I don't have tanktravel.cs script in my proyect of that tutorial, how is that script?
     
  9. Roulik

    Roulik

    Joined:
    Jan 15, 2018
    Posts:
    14
    I don't see any other difference between your tank and my tank, tanktravel and editor, i used editor 2019.1.14f1 to did tanks tutorial
     
  10. ethanzfurman

    ethanzfurman

    Joined:
    Mar 12, 2020
    Posts:
    5
    TankTravel.cs is a new script I made where I just copied and pasted the script from TankMovement into and changed the public class. Neither script works, though. I'll try the different editor and hopefully it will work. Thanks for all of your help.
     
  11. Roulik

    Roulik

    Joined:
    Jan 15, 2018
    Posts:
    14
    Delete that TankTravel from tank and from assets, there are something wrong with that. I do the same and my tank in inspector show diferent in that script component, i'm not sure if i explain correct my english is really bad.
    Just delete that script from tank and from assets and try again with tankmovement script
     
  12. ethanzfurman

    ethanzfurman

    Joined:
    Mar 12, 2020
    Posts:
    5
    I retried the whole thing with a different version, and it worked! Thank you very much for your help! :)
     
    Roulik likes this.
  13. KGERBR

    KGERBR

    Joined:
    May 17, 2020
    Posts:
    4
    There's a tutorial for adding AI to the Tanks tutorial game. Look for "Scriptable Objects" and it should come up.
     
  14. KGERBR

    KGERBR

    Joined:
    May 17, 2020
    Posts:
    4
    Has anyone had any luck adding a menu to the Tanks tutorial game? I've added a menu and can transition to it etc but always get the dreaded Input Axis Horizontal error.

    I was able to add two more tanks (so 3 AI and 1 player) and have set up the axis for them in Edit - Project Settings - Input Manager, so everything is working correctly before I try to add a menu.

    I kind of think it related to where the axis movements are declared, and maybe because the tanks get disabled and re-enabled each round, etc ... but it doesn't seem to matter where I call the menu transition, I always get the Axis error. I even tried adding a menu with just text and no buttons but it still comes up.

    Any ideas?
     
  15. frangagn

    frangagn

    Joined:
    Sep 20, 2018
    Posts:
    53
    Very good tutorial, but it's missing Step #6 in the website. Fortunately, it's on Youtube.....
     
  16. PriyankaKaria

    PriyankaKaria

    Joined:
    Sep 22, 2020
    Posts:
    1
    Does anyone know how to give mouse control to player 1?
     
  17. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    it's not missing it's just in a combined step called creating and firing shells.
     
  18. Risran

    Risran

    Joined:
    Jan 7, 2021
    Posts:
    1
    Which line is this?
     
  19. White_Panther

    White_Panther

    Joined:
    Oct 12, 2020
    Posts:
    1
    I need to do this tutorial as a school project! Now I have to add a script which lets the player get a Speedboost while Pressing a certain Key. I tried to insert it with the
    Input.GetKeyDown(KeyCode.R)
    in the TankMovement script:
    Code (CSharp):
    1. private void Move()
    2.     {
    3.         SpeedBoost();
    4.         // Adjust the position of the tank based on the player's input.
    5.         Vector3 movement = transform.forward * m_MovementInputValue * m_Speed * Time.deltaTime;
    6.         m_Rigidbody.MovePosition(m_Rigidbody.position + movement);
    7.     }
    8.  
    9.     private void SpeedBoost()
    10.     {
    11.         //Get a Speedboost when Boost Key is pressed.
    12.         if (m_PlayerNumber == 1)
    13.         {
    14.             if (Input.GetKeyDown(KeyCode.R))
    15.             {
    16.                 Vector3 movement = transform.forward * m_MovementInputValue * (m_Speed+5f) * Time.deltaTime;
    17.                 m_Rigidbody.MovePosition(m_Rigidbody.position + movement);
    18.             }
    19.         }
    20.         else if (m_PlayerNumber == 2)
    21.         {
    22.             if (Input.GetKeyDown(KeyCode.P))
    23.             {
    24.                 Vector3 movement = transform.forward * m_MovementInputValue * (m_Speed + 5f) * Time.deltaTime;
    25.                 m_Rigidbody.MovePosition(m_Rigidbody.position + movement);
    26.             }
    27.         }    
    28.     }
    The Player 1 should move 5 faster when pressing Key "R" and player 2 wehen pressing Key "P". It didn't work at all and the game just went on without even noticing the changes! please help! how can I get a Speedboost when pressing the key P/R? like what do I have to change and do I have to change anything in other scripts or settings?
    Thanks
    Lasse
     
  20. Titolas82

    Titolas82

    Joined:
    Jan 18, 2022
    Posts:
    2
    hello, I have created a powerUp to recover health to 100% but it only applies to one tank even if it is picked up by the other.

    SimpleCollectibleScript
    upload_2022-2-15_12-49-20.png
    TankHealth Script
    upload_2022-2-15_12-50-20.png


    https://youtu.be/De1p4EU88QI

    THANKSS
     
    Last edited: Feb 15, 2022
  21. Titolas82

    Titolas82

    Joined:
    Jan 18, 2022
    Posts:
    2
    upload_2022-2-17_10-6-48.png

    fixed, instead of calling the object in HealthTank I call it in the PowerUp Script.
    Thanks
     
  22. derekdung0

    derekdung0

    Joined:
    Jul 26, 2022
    Posts:
    1
    I need help with my tank game. The tank doesn't move with the tank renderers
     
  23. samgladiatorisbae

    samgladiatorisbae

    Joined:
    May 8, 2023
    Posts:
    1
    hello, i know im around 8 years too late to ask a question but i am hoping to get a answer. do you guys have any idea why the "players" layer doesnt exist, i have created a tank and also dragged in the complete tank and the difference is, on the tank mask section in the shell the "players" layer does not appear, i have also checked in the completed tank prefab and the layer at the top appears to be blank while still being able to take damage? and the tank i created cannot take damage. ive tried making my own player layer but that doesnt make a difference either, and i dont know if its an error in the script as Csharp hasnt told me that there are any errors. so if you know could you please notify me on how to fix this. thanks
     
  24. unity_5355E374EACCF3FE17A3

    unity_5355E374EACCF3FE17A3

    Joined:
    Jul 10, 2023
    Posts:
    1

    Thanks!
     
  25. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    You have written a '[HideInInspector] tag before that variable, remove it, and you'll see the targets. Good luck!
     
  26. ravenclaw07

    ravenclaw07

    Joined:
    Feb 12, 2024
    Posts:
    1
    For some reason, my GameManager script will not allow me to put my CameraRig object into the camera control slot. Any recommendations on a fix?
     
  27. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Not without seeing your code, please paste it into a code block using the code button on the forum so we can take a look :)
     
  28. gmijic_WebmasterGM

    gmijic_WebmasterGM

    Joined:
    Feb 15, 2024
    Posts:
    1
    Mine too, so I fix it this way:
    Changed in script:
    line
    public CameraControl m_CameraControl; // Reference to the CameraControl script
    change to
    public GameObject m_CameraRig; // Reference to the CameraRig Game Object.

    and add line:
    private CameraControl m_CameraControl; // Reference to the CameraControl script

    and in void Start method, add next line:
    m_CameraControl = m_CameraRig.GetComponent<CameraControl>();

    Now it works!