From Beginner to Pro: Mastering Unity's Colliders

  Рет қаралды 7,128

AnanDEV

AnanDEV

Күн бұрын

In this Unity tutorial, we'll be discussing how to create and use colliders in Unity. We'll cover topics like how to create colliders, OnCollision and OnTrigger events, how to set collision filtering preferences, and more!
If you're new to Unity or want to learn more about collision filtering, then this tutorial is for you! We'll cover everything you need to know to create and use colliders in Unity for efficient game development. Let us help you master Unity's Colliders!
****************************
LINKS MENTIONED IN THIS VIDEO:
Rigidbodies (Learn more about Collision Detection) 👇
• Rigidbody in Unity - E...
Collectibles (Collision filtering + Inheritance) 👇
• A Better Collectibles ...
Collision Detection Algorithms 👇
docs.unity3d.com/Manual/Conti...
Modular Castle Asset Pack 👇
assetstore.unity.com/packages...
Read more about Colliders 👇
docs.unity3d.com/ScriptRefere...
****************************
For doubts and stuff, join our discord club👇
/ discord
Check out my Instagram 👇
/ anandev.0
*****************************
TIMESTAMPS🔍
0:00 Colliders in Unity
1:07 How to add colliders
1:28 Compound Colliders
3:03 Physics Materials
3:27 Static and Dynamic Colliders
3:54 Collision Detection
4:07 OnCollision Events
6:20 Triggers
6:57 OnTrigger Events
7:50 Trigger Detection with compound collider (Example)
9:07 Filtering Collisions
9:20 Using Tags
9:53 Using Layers
10:35 Tags vs Layers
11:19 Using GetComponent() function
11:48 Using Collision Matrix
12:35 IgnoreCollision()
13:36 Which Collision Filtering to Use?
13:58 Class Inheritance and Collisions?
14:34 Outrooooooo
#unitytutorials #gamedevelopment #unity3d #unitytutorial #collision
If you have any questions, comment below, and I will try to answer them to the best of my knowledge.
Thank you for watching the video and reading this description. Take care.

Пікірлер: 40
@anandev
@anandev Жыл бұрын
Sorry for the loud sound effects 😭 That's it. Have a beautiful day :)
@reddead1668
@reddead1668 6 ай бұрын
Criminally underrated unity game dev youtube channel Love the tutorials
@anandev
@anandev 6 ай бұрын
Thank you so much!!! This means a lot 😭❤️
@yawnyawning
@yawnyawning 7 ай бұрын
im using Unity nearly ten years and this is one of the best tutorial ive ever seen
@anandev
@anandev 7 ай бұрын
Thank you soo much!!! This means a lot ♥️
@bgoldpanda7265
@bgoldpanda7265 4 ай бұрын
Great video! Going to implement the use of collision matrix now, I was struggling with an easy way to do this before I saw your tutorial. Keep up the great work Anan!
@anandev
@anandev 4 ай бұрын
Thank you so much!! I'm glad the video was useful! 😊 Collision Matrix is a really powerful tool, and it effectively eliminates unwanted interactions with ease. If you want, there's a video on my channel for collectibles, which uses this collision matrix to simplify collisions even further!
@SepiaDragoonGR
@SepiaDragoonGR 6 ай бұрын
This is literally a wealth of experience and knowledge, thank you very much Sir
@anandev
@anandev 6 ай бұрын
Thank you so much!! I'm glad I'm doing what I'm doing! So nice of you!
@SepiaDragoonGR
@SepiaDragoonGR 6 ай бұрын
@@anandev by any chance, I am working on a 3D space adventure game. Would you be interested in a collab?
@anandev
@anandev 6 ай бұрын
@@SepiaDragoonGR I would love to collab! What kind of work are we talking about?
@dusklightcreations3951
@dusklightcreations3951 Жыл бұрын
The best video i stumbled upon .you earned a sub bro,the only request i would have is upload frequently and stick to the topics like this and can you tone down sound effects a bit low .
@anandev
@anandev Жыл бұрын
Thank you so much! I try my best to upload, but life keeps throwing rocks at my way. And yes, I forgot to tone the sound effects down. Honest mistake :)
@gabreiliusgen4519
@gabreiliusgen4519 Жыл бұрын
Here before this channel blows up!!
@anandev
@anandev Жыл бұрын
Me shall remember this 🐼 thank you so much
@devSSEM
@devSSEM Жыл бұрын
You made one of the best Unity tutorials I've ever seen.😍
@anandev
@anandev Жыл бұрын
Wow, thanks! I'm happy it was useful 🐼
@bigedwerd
@bigedwerd Жыл бұрын
This deserves more views. So concise! One way you could have gotten around the compound collider for your character is to create an empty object in the hierarchy of your player with a tag of "PlayerPresence" and a trigger capsule collider then check if the door has OnTriggerEnter/Exit with that tag. Your example is good if you want to be more precise, but in the case of the door you probably don't need to be.
@anandev
@anandev Жыл бұрын
Woah! That makes total sense. I'm not sure whether triggers could trigger OnTrigger events with other triggers 😵 Btw, I'm glad you liked my video 🥰🌱
@bigedwerd
@bigedwerd Жыл бұрын
@@anandev I tested it out to be sure and got it to work. I made a rudimentary model with a body and limbs all with "Player" and then the trigger with "PlayerPresence" I mentioned. I've been using more empty game objects lately for simple things like spawning a cannonball out of a cannon rather than doing funky math. Your approach is very necessary for different situations and a great reminder on how the system works. Your videos are awesome! I just discovered your channel so I'm looking forward to checking out the rest.
@anandev
@anandev Жыл бұрын
@@bigedwerd That idea is definetely a simple game changer for me. Defenitely helps with not overthinking and complicating things 😂 And I'm glad my vids are helpful! Thank you very muchhh
@Tormator
@Tormator Жыл бұрын
Thank you for your video, clear, concise and very educational. Almost always, we think that because they are basic topics they are not so important, but they really are. I just discovered your channel and I find your content very good. Great job!
@anandev
@anandev Жыл бұрын
Woah! This made my day! Thank you sooo muccchhhh
@BbVortexMortinghan
@BbVortexMortinghan 5 ай бұрын
Good video
@anandev
@anandev 5 ай бұрын
Thank you so much! I'm glad it was useful!
@Spyboticer
@Spyboticer Жыл бұрын
Been having a hard time with my collisions in my prototype,this vid might have been the answer to my issues😂
@anandev
@anandev Жыл бұрын
Yo I'm glad this could help ☺😬
@v0ltdev
@v0ltdev Жыл бұрын
To not get performace hit if you use the getComponent function and returns null use the tryGetComponent function instead which returns a boolean if the component you are looking for is null or not and outputs it if it isnt without any performance hits if its not
@anandev
@anandev Жыл бұрын
Yes TryGetComponent() works. I looked into it, but I couldn't find any actual evidence for the performance gain anywhere online. But yeah it does makes sense and maybe faster.
@anandev
@anandev Жыл бұрын
Thanks for sharing this! 🥰
@v0ltdev
@v0ltdev Жыл бұрын
@@anandev visual studio's intellisense tells you that
@anandev
@anandev Жыл бұрын
@@v0ltdev For real? I haven't noticed lol 😂
@fokeyjo
@fokeyjo 5 ай бұрын
Regarding your problems with the door, why did you not use a separate trigger collider for area interactions like that? Also, I'm no games pro, but I wonder if it's more efficient to disable the detailed composite collider whilst there's nothing nearby to interact with, just have a larger encompassing trigger collider that when anything of interest is nearby it switches the detailed mesh on. Maybe then you wouldn't even need the composite collider operating? Probably overkill or causes a delay turning it on/off all the time - and depends on the game, of course.
@anandev
@anandev 5 ай бұрын
If I use a separate collider on the body itself, it becomes a part of the compound collider. The compound colliders needs a Rigidbody and a collider on the root GameObject, and if we try to make it a huge capsule, then it will also trigger collisions like every other collider in the body and disabling such a collider may not be a wise thing to do especially since it's on the root GameObject 😅 The idea you suggested would probably work, but I think it takes too much memory, and you need to manually place the area of interest triggers and stuff like that. Instead, I would recommend finding a solution through code, just like I did in the video, the CPU does it pretty fast, and I think it's way better (in the long run) and you only need to solve it once! There is a lot of memory usage that could be avoided if we spend some time doing the code. However I would recommend creating a function or something in the character script itself like IsTouchingCollider() or something like that, so that you don't have to write it again and again for every interaction.
@Abdel-Qader
@Abdel-Qader Жыл бұрын
you are doing great work .. keep up .. can you make a video about how is unity working in background i mean what is the main class in unity and what is mean by namespace and this stuff thanks
@anandev
@anandev Жыл бұрын
Thank you so muchh!!! Well, there is no single "main" class in Unity. It works when a lot of classes work together. I will see what I can do for a video about it. Will need to research. I definetely can make a video about namespaces, and I'll add it to my priorities. Once again, thank you so much for being a part of the gang
@andisarifi5805
@andisarifi5805 6 ай бұрын
2:45 KILLED ME HAAHAHAHAHAH
@anandev
@anandev 6 ай бұрын
Haha! 😂 Humour based on my pain 😭
@jean-loupmartin6067
@jean-loupmartin6067 Жыл бұрын
Very cool vidéo ! The sound effects are a bit too loud for me :)
@anandev
@anandev Жыл бұрын
Thank you! Sorry about the sound effects volume, I'll tone it down for the next one ☺
Events & Delegates in Unity
13:20
Game Dev Beginner
Рет қаралды 52 М.
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 11 МЛН
Пранк пошел не по плану…🥲
00:59
Саша Квашеная
Рет қаралды 6 МЛН
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 10 МЛН
Rigidbody in Unity - Everything You Need to Know
9:03
AnanDEV
Рет қаралды 23 М.
Coding Adventure: Portals
16:06
Sebastian Lague
Рет қаралды 1,3 МЛН
The Power of Scriptable Objects as Middle-Men
17:41
samyam
Рет қаралды 121 М.
The 6 Design Patterns game devs need?
24:20
Jason Weimann
Рет қаралды 364 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 698 М.
Better Coding in Unity With Just a Few Lines of Code
15:27
Firemind
Рет қаралды 305 М.
When Your Game Is Bad But Your Optimisation Is Genius
8:52
Vercidium
Рет қаралды 1,4 МЛН
Improve Your Platformer with Forces | Examples in Unity
7:01
Dawnosaur
Рет қаралды 170 М.
Don't use the Unity Animator, Use Code Instead! - Tutorial
19:16
Small Hedge Games
Рет қаралды 14 М.
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 11 МЛН