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!

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:


  1. Hi, can I ask you something. How to open your project in Unity ?

  2. What If I wanted to put an animation on the track wheels? where Im supposed to put it?

  3. Hi, Peter. Thank you for sharing such amazing tutorial for 2D shooting game. I have a question regarding player input where in my case I'm using virtual joystick to rotate the turret instead of the turret aiming by following the mouse. What can I do to modify the input for joystick drag rotate. Thanks again

  4. HI Sir, i am facing a problem during rotating the Tank .As when i rotate the Tank so its do like a Circular motion , mean its not rotating from its on axis.Although i checked my Code many time and its correct, Please let me know about my problem .using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class TankController : MonoBehaviour

    public Rigidbody2D rb2d;
    private Vector2 movementVector;
    public float maxSpeed=10;
    public float rotationSpeed=10;
    private void Awake(){


    public void HandleShoot(){
    public void HandleMoveBody(Vector2 movementVector){
    public void HandleTurretMovement(Vector2 pionterPosition){

    private void FixedUpdate(){
    rb2d.velocity=(Vector2)transform.up * movementVector.y * maxSpeed * Time.fixedDeltaTime;
    rb2d.MoveRotation(transform.rotation * Quaternion.Euler(0,0, -movementVector.x* rotationSpeed *

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

  6. 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.

  7. 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?

  8. 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)?

  9. 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?

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

  11. 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

  12. 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.

  13. 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


    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.