Unity - How to Detect Collision in C# [Using Colliders]

preview_player
Показать описание
In this tutorial we discuss adding colliders on our objects so that we can detect collision within our script.
============
In this video, you will learn:
0:55 - Choosing the right collider for your environment
1:05 - How a collider works
1:30 - 2D and 3D colliders to use
2:05 - Adding a Circle Collider 2D
3:35 - Adding a Box Collider 2D
4:19 - How to use isTrigger
4:45 - Detecting Collision in C#
6:10 - Using Instantiate to load an explosion
7:00 - Destroy on Collision

COPY & PASTE CODE FROM THIS TUTORIAL:

PREVIOUS VIDEOS:

MORE TUTORIALS:

WEEKLY DEVELOPER STORIES AND TIPS:
Рекомендации по теме
Комментарии
Автор

OH MY LORD YOU DONT KNOW HOW LONG I'VE BEEN LOOKING FOR THIS!!! HONEST TO GODD YOU ARE THE ONLY ONE WHO ACTUALLY MADE THIS EASY AND BEST TO UNDERSTAND

ThatStunnenDude
Автор

THANK YOU SO MUCH, YOU SAVED MY GAME! I also left a suggestion if anyone get's the Debug error, thanks again!

bubberiffic
Автор

Thanks so much! I'm a beginner programmer in C#, and I just started making basic games, this helped a lot, thanks.

photonninja
Автор

Oh my stars, thank you. I am definitely going to subscribe, this is gonna be worth it.

skiesquiggles
Автор

You have great pacing in your tutorials and give good explanations for why something needs to be done. I'd like to thank you for both of those things because it seems to be rare from other tutorial creators

tonymp
Автор

Hey look, its finally a unity tutorial which i a. understand and b. can use later on by myself!! the rarest of all kinds.
Keep it up.

marschma
Автор

The tutorial is clear in instruction and I can easily follow it. Thank you for this!

amogh
Автор

your tutorials are really good and useful. i just solve a problem with your explanations.
keep up the good work

nutcrackersh
Автор

I love you, like seriously I do. You are an amazing human being and should be gifted a million dollars.

Noisey_fox
Автор

Bro! Thank you so much. I’ve been trying for ages to figure out why I couldn’t make my tree solid when my character touched it. I had the correct colliders but I had the “is trigger” box checked the whole time because I didn’t know what that meant.

smashdriven
Автор

Finally a tral tutorial that doesn't just says what to do but explains

Bebe-wbun
Автор

I watched every of your tuto, they are well explained and enjoyable, thanks you

vp
Автор

that intro made me go deaf, but the tutorial worked like a charm! Tysm!

TheDuccyGaming
Автор

this is the best tutorial i've watched

onszik
Автор

thanks mate helping with my school assignment a lot

Arina-qwpu
Автор

If you don't have explosion animation just use this:


Debug.Log("Hit Detected");
Destroy(this.gameObject);
Scene scene =
SceneManager.LoadScene(0);


//I used this to reload the scene...will change it according to the game but for now it works good...
Thanks for these tutorials, I was able to learn a lot from these.

lawlietlight
Автор

Thanks for the video, really to the point and easy to understand.

BenovskyGM
Автор

God dayum I had been here for 2 days straight looking at different freaking codes for c* for detection of a cube and a ball to destroy it, I tweaked a bit your code and it worked thank the lord! great vid! earned my subscribe and like!

paulofaria
Автор

You are a lifesaver.
Thank you very much.

xlpatelx
Автор

this helped me a lot thank you for an awesome tutorial

desertmoon_cho