Collision Layers in Unity 2D - Tank game tutorial P5

In this Unity tutorial we will explore collision layers and collision matrix to improve the way we detect the bullet collisions. This is part of the 2D Top Down Tank game tutorial series. Playlist • Top Down 2D Tank Game
00:00 Introduction
00:48 Recap
01:05 Bullet collides with everything problem
02:05 What are collision layers?
03:00 Creating collision layers
05:13 Setting Collision Matrix
06:51 Testing the result
07:13 Preventing bullet and self collision
07:59 Why my trigger doesn't work?
09:17 Support me maybe?
Resources
Scripts and UnityPackages: github.com/SunnyValleyStudio/...
Full project: drive.google.com/drive/folder...
Would you like to learn how to make a 2d shooter in Unity?
courses.sunnyvalleystudio.com/
You can support me through Patreon:
/ sunnyvalleystudio
Assets used:
www.kenney.nl/assets/topdown-...
github.com/sparklinlabs/super...
Join the discord:
/ discord

Пікірлер: 20

  • @FM_GOBi
    @FM_GOBi2 жыл бұрын

    Thank you! Another great video in this series.

  • @hhcdghjjgsdrt235
    @hhcdghjjgsdrt2352 жыл бұрын

    I learned many new concepts like unityevents, object pooling, scriptableobject by your videos. Thanks for making these intermediate contents free.

  • @SunnyValleyStudio

    @SunnyValleyStudio

    2 жыл бұрын

    You're very welcome! Thanks for watching :)

  • @featherlitegames
    @featherlitegames Жыл бұрын

    The unity documentation on the matrix left me really confused, thank you so much.

  • @SunnyValleyStudio

    @SunnyValleyStudio

    Жыл бұрын

    Glad it was helpful! 👍

  • @XtrminatR7
    @XtrminatR76 ай бұрын

    This guy deserved more attention.

  • @SunnyValleyStudio

    @SunnyValleyStudio

    6 ай бұрын

    Thanks 🙂

  • @abdulkadirdursun6072
    @abdulkadirdursun60723 жыл бұрын

    Great video. Thank you for tutorial :D

  • @SunnyValleyStudio

    @SunnyValleyStudio

    3 жыл бұрын

    Glad you liked it!

  • @ramik1237
    @ramik1237 Жыл бұрын

    Thank you, it helped me a lot!

  • @SunnyValleyStudio

    @SunnyValleyStudio

    Жыл бұрын

    Thanks for watching 🙂

  • @takazukisan7467
    @takazukisan7467 Жыл бұрын

    THANK YOU BIG BRO

  • @SunnyValleyStudio

    @SunnyValleyStudio

    Жыл бұрын

    Thanks for watching 🙂

  • @dragonballz3686
    @dragonballz36862 жыл бұрын

    Bro, I am making a 2d top down space shooter. There is a problem in shooting system, that is , when enemy is shooting and I shoot, then the player's bullet is colliding with enemy bullet and the player's bullet is destroyed but the enemies bullet is not destroyed. Can you tell me what to do to make the both bullets passing away without any collision.

  • @SunnyValleyStudio

    @SunnyValleyStudio

    2 жыл бұрын

    Hey! Generally you want to use a Collider set to be Trigger (it will not "push" on anything if you use a dynamic RB). You can create a custom *Bullet* script that will have *OnTriggerEnter2D*. This way you can ask *if(collider. GetComponent()}) return; * - so "have i collided with a bullet? Do nothing in that case". The downside is that you need to do the same for the Enemy/Player object - define what happens when those collide with your bullet. I hope it helps!

  • @dragonballz3686

    @dragonballz3686

    2 жыл бұрын

    @@SunnyValleyStudio yeah thanks man.😊

  • @Zerovity
    @Zerovity2 жыл бұрын

    how to collide bullet with tilemap walls (composite collider 2d and tilemap collider 2d) can anyone help me , the bullet is passing through the walls.

  • @SunnyValleyStudio

    @SunnyValleyStudio

    2 жыл бұрын

    In Unity for collisions to work you need a Collider (docs.unity3d.com/Manual/class-TilemapCollider2D.html) and a RigidBody based movement. You can watch my tutorial about collision detection to get a better idea about how 2D Physics works in Unity kzread.info/dash/bejne/h3VmqJqsY8mpfNY.html

  • @Zerovity

    @Zerovity

    2 жыл бұрын

    @@SunnyValleyStudio thanks man

  • @kingdomlamb7741

    @kingdomlamb7741

    Жыл бұрын

    @@SunnyValleyStudio love this tutorial, but I want to know if there is a way that you can have a player “crouch” or avoid getting hit by bullets next to this type of collider if they press a “crouch” button/key. So the players can essentially take cover and pop back up to return fire. Is that possible? And if so how?