Tank Movement in Unity 2D - Tank game tutorial P2 - panicarts.com

Tank Movement in Unity 2D – Tank game tutorial P2

Sunny Valley Studio
Views: 5079
Like: 104
In this Unity tutorial we will implement a simple tank movement. This is part of the 2D Top Down Tank game tutorial series. Playlist

00:00 Introduction
00:29 Summary of previous video
00:56 Creating tank game object
02:10 Getting Player Input
03:54 What are Unity Events
05:02 Finishing Player Input Script
09:09 Creating Tank Turret Game Object
12:32 Creating Tank Movement Script
13:15 Using RIgidbody2D for movement
15:14 Rotating RigidBody2D
17:29 Turret Movement Logic
19:55 My turret is rotated incorrectly!

Resources
Scripts and UnityPackages:
Full project:

Would you like to learn how to make a 2d shooter in Unity?
Udemy course:

You can support me through Patreon:

Assets used:

Join the discord:

12 Comments

  1. My tank keeps just going around and around in a circle, Would anyone know why?

  2. Hello there, great video. However there's an issue in the PlayerInput script.

    public UnityEvent<Vector2> OnMoveBody = new UnityEvent<Vector2>();

    The above line says "CS0144: Cannot create an instance of the abstract type or interface 'UnityEvent<Vector2>'

    Same as the line below that one.

  3. Hello, in my game, when i press the right and left arrows, the tank (that im using a different asset) moves like it draws a circle around circle. Not turning in its own axis. How do i fix it?

  4. Great lesson. But I have a problem – is not working movement in front and reverse way. I create almost the same project with different assets.Can you help me fix this bug(Unity 2019.3.6f1& Visual Studio 2019)?

  5. 15:00 isen't using Time.deltaTime in fixed update wrong? Since fixedupdate should run the same amount no matter how many frames have been completed, so correcting according to frame speed (by using Time.deltaTime) would create the problem, you are trying to solve?

  6. Lines 13 and 14 for Vector2 comes up with errors and I don't know how to fix it. any suggestions?

  7. Loving the series so far, quick issue with my script. When I try to attach it to the player game object it says "Can't add script compentent 'PLayer input' because the script class cannot be found."

    Any tips on how to procede would be appriceated

  8. Hi Peter. I'm loving the series and learning a ton. I have a question.
    12:33 – I don't know if you remember this project. But I keep wondering, why did we create this Tank Controller script? Couldn't scripts AimTurret, TankMover and Turret subscribe themselves directly to the Player Input instead of having this "middle man" doing the subscribing, and then telling them what to do. I bet there is a reason you chose this approach but I can't figure out the advantage of it.
    I haven't completed the series yet, I'm only on the episode 7 currently.

  9. Hi there, im currently having auch a problem that i cant continue my project, the problem is in the Player Input, im Using Unity 2020 latest, and at first i followed by writing the

    GetBodyMovement();

    And if i right click it, it doesnt have generate method, only local, which only made it

    Object p = GetBodyMovement ();

    And the Unity Events, its not highlighting,

    In the
    Public UnityEvent
    If i right click and quick actions that you told ,theres no option like that , i really need an answer tnx.

Leave a Reply

Your email address will not be published.