After one hour of tears and headsmahes i found this video and the title saved my life... i didnt use 2D... Even tho i used 2D components hundrets of times in the past... Its 4 AM now and i can peacefully go to sleep, tyvm.
@data_corrupted3 жыл бұрын
aaand you just saved me
@foxfirefive3 жыл бұрын
@@data_corrupted i think you might need to fix your data.
@friedrichhieronymus87864 жыл бұрын
I almost quit my first game after 3 days of tweaking the code, turns out it only needed a rigidbody, damn, I owe you one a big thanks
@junejuly5324 жыл бұрын
If you learnt Physics and mathematics well in High school, You will know the engine better.
@RomainDelmaire4 жыл бұрын
@@junejuly532 Don't shame someone on what they didn't learn. Encourage them for what they are learning.
@junejuly5324 жыл бұрын
@@RomainDelmaire I'm sorry if my comment meant shaming. it was not the intention. I soon realized how important Physics and Maths are to Game development.
@nathanmcconnell99914 жыл бұрын
@@junejuly532 Knowing physics and knowing you needed a RigidBody in Unity are not the same thing.
@junejuly5324 жыл бұрын
@@nathanmcconnell9991 In physics, you learn about Rigidbody. Some of the requirements when you go to uni to learn game programing is Physics and maths.
@Kewie13372 жыл бұрын
I needed this so badly for a long time. I am so happy to finally discover your channel as it is truly inspiring work :) Thank you for everything you have contributed to the unity community Code Monkey!
@CodeMonkeyUnity2 жыл бұрын
I'm glad the video helped you! Thanks!
@abdessamadcherrat52752 жыл бұрын
Some call him The Next Brackeys Others call him a Legend I call him "The man that the saved me from starting a new project by ACTUALLY making a good Tutorial about Collisions "
@hardgames41045 жыл бұрын
This is a really good tutorial, because it does not only show one way to do something and is over, but it covers several ways how to do and how not to do the topic the video is about. This makes things easier to get put together inside the brain of someone watching. Good work.
@CodeMonkeyUnity5 жыл бұрын
Thanks! Glad you liked it!
@freemoncodes Жыл бұрын
My man, I spent like 45 minutes trying to figure this out. Was missing the all important 2D at the end. Thanks much!
@joaocarvalho71894 жыл бұрын
I searched on many videos and websites, and now I finally found how to make the player not pass through the walls ,Thank you!
@ZeroIdeas900010 ай бұрын
Thank you so much, I have been working on my first game ever. Even though it is a 3d game this finally got a object to detect the thing- THIS SAVED ME SO MANY HOURS.
@CodeMonkeyUnity10 ай бұрын
I'm glad the video helped!
@wiltongarcia48644 жыл бұрын
Your channel is very good, your English is very clear and the speed that you speak is very nice, helpful for those non-natives
@canerozdemir41955 жыл бұрын
I am a simple man, I see Code Monkey and I like it.
@serialchiller91835 жыл бұрын
Aynen :)
@iDigvijaysinhG5 жыл бұрын
Man you stole my line, :) But yes we both are simple men for sure
@canerozdemir41955 жыл бұрын
@@iDigvijaysinhG Sharing is caring, right?
@breadofgodd4 жыл бұрын
I was going mad trying to get OnTriggerEnter to work, you're awesome!
@elbreadroh4 жыл бұрын
I see a fellow Bread, alliance??
@croeusjawad97443 жыл бұрын
I made a project and the walls were not working, then I permanently deleted the project and made a new one and I felt like to quit on this idea, but then you cam and saved me from rewriting 567 lines of code. love u Thanks :D
@_decoded_20 күн бұрын
OH MY GOD 2 HOURS OF PAIN BECAUSE I DIDNT HAVE A RIGID BODY. In all seriousness this tutorial was a life saver, sending love man ❤
@CodeMonkeyUnity20 күн бұрын
heh I'm glad the video helped you! Thanks!
@AraragiAriel2 жыл бұрын
I was looking to learn more about collisions, but what ended up really helping me on the video was discovering the Rigidboy2D.MovePosition function, which made me found out the solution to my player movement. I was doing it using the transform before, which wasn't working properly when moving towards terrain
@loklo3 жыл бұрын
2 years later and still saving lives, great tutorial saved me a lot of time :)
@Phalanx33514 жыл бұрын
OHH! THANK YOU! my mistake is that I was actually using OnCollisionEnter insted of OnTriggerEnter! never notice this till now =-=
@iamyourfather69414 жыл бұрын
mine is OntriggerEnter instead of OnTriggerEnter... been spending hours for a spelling mistake T _ T
@Phalanx33514 жыл бұрын
@@iamyourfather6941 haha! that's C# for yah
@noether94475 жыл бұрын
Found you through the ads and really liking your videos. Subscribed
@CodeMonkeyUnity5 жыл бұрын
Glad you like the videos!
@swedstonetv3222 жыл бұрын
Thank you :) After 5 hours of finding the problem I've finally fixed it
@diegocarrionportilla87183 жыл бұрын
I f***ing love you man, you have saved me
@CodesnippetBiz4 жыл бұрын
very clear explanation, thank you so much, now I can fully understand differences between these kind of collisions!
@anirbankarmakar20375 жыл бұрын
Awesome video ,I really understand the concepts of collisions better now. Can you also make more on 3d development that would be really helpful Thanks,love your videos
@illuminith64053 жыл бұрын
Thank you for the help. I was struggling a lot to make the collider work but now it works. I am new to unity and C# and you are of great help.
@Gurseerat_Singh4 жыл бұрын
Hay code monkey bro i frickin love you omg you saved me actully i needed the function on collision exit and i was not knowing that this finction even exists bro i was almost going to quit my game but you saved it bro i am sooo frickin glad i found your vid
@DARK_AMBIGUOUS3 жыл бұрын
Thank you, my game really coming along, I just added split screen multiplayer
@utilityy4 жыл бұрын
You are actually so cool. Thank you so much for all of these amazing tutorials you are producing. :)
@swepo5719 Жыл бұрын
o m g, i freaking love you, i have been looking for solution for so long and no one says about rigidbody2d XDDD
@abrahamliz25594 жыл бұрын
I was going crazy... could not get a state change inside the trigger. Watching the debugs you used solved my problem lol!! Many thanks!!
@thefakejonfischer4 жыл бұрын
Thank you so much! I have been trying to make a title screen, and the trigger wasn't working. I found this video 30 minutes after midnight, and it allowed me to go to bed.
@DridgeDEU7 ай бұрын
Amazing, solved my problem super quickly. Love you!
@CodeMonkeyUnity7 ай бұрын
I'm glad thte video helped you!
@IsaacJairi4 жыл бұрын
THANKSSSSSSSSSSSSSS MAN YOU JUST SAVE ME, I WAS 6h ON THIS
@gameovercom4 жыл бұрын
Man, I had the same problem, I was trying to play an animation trigger with just the collider, when I tried this, I almost make you a coding religion, haha. Thanks man.
@namenight71584 жыл бұрын
Helped me a lot! Looking forward for your game on steam!
@subzero47874 жыл бұрын
Thanks bro it was helpful... First I thought my script was wrong and deleted it and wrote again and again deleted... But now it's working
@pholux56472 жыл бұрын
Thanks Code Monkey You Really Helped Me A Lot!
@aminmk6974 жыл бұрын
bruv I was giving up making a (TOP DOWN DODGER) game because of the rigidbody :) I just subbed to the game dev god
@Motyy10 ай бұрын
THANK GOD IT WORKS YOU ARE A GENIUS
@CodeMonkeyUnity10 ай бұрын
I'm glad the video helped!
@bbuddyyeapp35573 жыл бұрын
Thank you so much!!! I was finding the way that can solve the problem which is first explained in your video! Thank you!!
@areion8192 жыл бұрын
Thank you for this video, I was stuck wondering why my collisions wouldn't work.
@hhhl35553 жыл бұрын
Ты легенда. Спасибо за детство
@Ranoluq Жыл бұрын
Bro thank you, i so confused when i making, but you explain this. Thank You
@TechGuyDane2 жыл бұрын
This was very helpful. You're the 🐐
@redfoxlightning3 жыл бұрын
THANK YOU turns out i just needed 2D at the end. thanks lots
@samuellucaslimasoares90102 жыл бұрын
Thanks very much! This tip saved my work, congratulations!
@ProfessorNova424 жыл бұрын
THANK YOU!! It got stuck at this problem for over an hour.
@makemoneyonlinewithjannie3 жыл бұрын
Thanks for this, I needed this tutorial today, I was doing colliders and triggers were set up perfectly, the only difference was my Player never had a rigidbody, so weird that it needs that.
@alvinmanoj703 жыл бұрын
if I had 3 wishes, my first wish will that you will have a million subscribers
@CodeMonkeyUnity3 жыл бұрын
Thank you!
@sasakiluna4 жыл бұрын
the trigger still doesn't respond in the debug code for me
@jordanbazin70674 жыл бұрын
Me too :/
@ZodakZach3 жыл бұрын
Same unity broke ass engine
@rodrigogriner9904 Жыл бұрын
Nice! You saved my team
@CodeMonkeyUnity Жыл бұрын
I'm glad the video helped you!
@nathaliaperes13924 жыл бұрын
This was really really helpful, thank you very much!!
@dwlg3 жыл бұрын
Code Monkey saves the day again! woop thx man!
@Fiedroz4 жыл бұрын
Nice! I was using a 3d collider for 2d game, thanks for helping! :)
@footballgirl483 ай бұрын
Thank you so much for this video !! Really helpful!!
@CodeMonkeyUnity3 ай бұрын
I'm glad it helped you!
@crazyone3494 Жыл бұрын
OnVoidStay2D That line of code saved me! I was trying to make an attack for my character, it is a sword slash, due the circunstances i had to use the Polygon collider as a trigger, then it was simple, i would press the button, if it detected an object with the enemy tag in range it would play the damage animation while removing a life point. The problem was: i didn´t read the whole Unity manual so the only OnTrigger/OnCollider i knew was OnTriggerEnter, from here you can guess the problem. Really stupid of my part....
@KhaledHakim4 жыл бұрын
Keep up the great work buddy. I wish you success and more of it.
@James-zp5ly3 жыл бұрын
Hello, great video but i didn't manage to solve my problem, was wondering if i could have some of your time. Currently, my player has the following components: transform, renderer, animator (custom script), rigid body 2D, box collider 2D as well as a movement script. The tilemap i want the player to interact with has: tilemap, a renderer, tilemap collider 2D. All these components have their default settings (eg: the player is a dynamic object not kinematic), and my problem is very odd, my player can walk across the floor, will 'hit' the ceiling and not go any higher, but for some reason can pass through the tiles left to right; so my problem is that the x axis collisions are working (as i can walk on them), but my y axis doesn't seem to (as my player can pass through them when walking left to right). Thank you for any help, James
@harneetsingh9420 Жыл бұрын
Life saver always, Thanks Hugo :)
@dhankumari72905 жыл бұрын
Your teaching ability is quite exceptional 👌👌👌👌👌👌👌 I really love it💖💖💖💖💖 Thanks as always uploading Such information viedo 🙏🙏🙏🙏🙏🙏
@serialchiller91835 жыл бұрын
Amazing as always.
@itz_ak40852 жыл бұрын
This is very helpful, I Subscribed :)
@Miki-gd4rq Жыл бұрын
Very helpful and great explanation, thanks man
@neozoid70092 жыл бұрын
Love your Tutorials . Awesome and simple explanations
@Excess-qn7qh2 жыл бұрын
you make my day ... thank you !!!
@fallingstar_Yas3 жыл бұрын
So for some reason, none of the triggers or collision code work. Even when there there a rigidbody. it just doesn't detect that the player and the object is touching. like the player cant go through the item but it not sensing that theyre touching
@stakes_z2 жыл бұрын
Love your videos. They help me a lot. I'm having a problem now and I dont know how to find a solution. I need to detect areas in a sphere with mouse click, like a globe. Do you know how I can do that?
@CodeMonkeyUnity2 жыл бұрын
You can use Physics.OverlapSphere(); or Physics2D.OverlapCircle(); It will find all objects will colliders within range
@stakes_z2 жыл бұрын
@@CodeMonkeyUnity Oh nice! I'll check that. Thank you! So what I need to do is include a collider for each region I want to detect on the sphere and put all as sphere children?
@CodeMonkeyUnity2 жыл бұрын
@@stakes_z Yes, if you have your globe with separate mesh parts that you want to select, just add a Mesh collider to each part. Then when when you click you can just do a raycast if you want to test a single point kzbin.info/www/bejne/Zpu3gX6waMyUatk Or use Physics.OverlapSphere if you want to test with a bit of range
@stakes_z2 жыл бұрын
@@CodeMonkeyUnity Awesome! Thank you so much! I'll create my globe with multiple meshes and try it. Thank you
@stakes_z2 жыл бұрын
Hi. I would just like to say that it worked. I took meshes for each region of the map, put a mesh collider on each one and used your tutorial on clicking 3d objects as a base. Thank you very much! :D @Code Monkey
@GustavoPLima3 жыл бұрын
you save me again! thanks from brazil
@luke4djojo4 жыл бұрын
3:08 - legend says this is the moment a young naive man somewhere west in brazil raged with the intensity of a thousand Suns.
@wizarddude30584 жыл бұрын
Are you talking about yourself?
@xXC0rn3rXx4 жыл бұрын
Really cool video, but I have a problem. If I want one object to collide with something and also to be trigger to something, how can I achieve this? (for example a projectile that bounces off the walls but effects the player as trigger)
@DayzeXzxR2 жыл бұрын
+
@christo-j55074 жыл бұрын
Great work and you're so excellent! Helped me a lot.
@DataversePH4 жыл бұрын
Happy for everyone that makes their game works. Unfortunately, mine is now working. I have a rigidbody2d, boxcollider2d for my player, and a gameobject which has a boxcollider for the trigger. And also in my script, I used OnTriggerEnter2d. But it still doesn't work. Send help please.
@CodeMonkeyUnity4 жыл бұрын
Your gameobject needs a BoxCollider2D, not BoxCollider
@dansv97784 жыл бұрын
well i have rigidbody and doesn't work. I made lots of functions in the scene with triggerenter and they work...the collision layer are all checked
@BeardaneLope4 жыл бұрын
Dan SV I have the same problem
@stepaburianek89943 жыл бұрын
I WAS SEARCHING FOR THIS FOR HOURS YOU SAVED MY COMPUTER FROM ME XDD
@CodeMonkeyUnity3 жыл бұрын
I'm glad you found it helpful!
@mynameisDuck4 жыл бұрын
Dude I had everything right except I was using OnTriggerEnter instead of OnTriggerEnter2D! Thanks!
@watcher27474 жыл бұрын
For some reason it's still not working for me, any ideas what could be the possible reasons?
@quentinyahia3524 жыл бұрын
Hi, i get the same issue and i add a rigidbody to the two object (put on static on the trigger object and dynamic to the player) and it works, hope it was useful
@TechnoMichaSDL3 жыл бұрын
i have a 2D Player Object with a Child 2D Object but i want to use the Child Object as Collision detector but how?
@madbitscience62303 жыл бұрын
Great tutorial! Thank you so much!
@well58324 жыл бұрын
increible Thanks CodeMonkey:D
@bananaramaman90312 жыл бұрын
Thank you for this video!
@jmiller62243 жыл бұрын
So helpful, thank you as always!
@ManWhite114 жыл бұрын
In my game when player get into a coin, it can trigger 2 times because I have 2 colliders on my player. How can I fix this?
@CodeMonkeyUnity4 жыл бұрын
Are you testing with a script placed on the coin? Maybe add a simple boolean to your collision script and change it on the first collision it detects
@sabeelm910 ай бұрын
Nice, I found the issue with mine being that I was using the 3d collision and not 2d! Only figured out when I copied your code out by hand lol
@CodeMonkeyUnity10 ай бұрын
Yup I've made that mistake myself several times when I was a beginner
@jamaass4 жыл бұрын
Thank you! You saved my life!
@collosalcake2362 жыл бұрын
your typing speed is faster than light omg
@Steve-gi2yj3 жыл бұрын
ok I answered my question, but the problem still remains, when I put my character from Kinematic to Dynamic on the rigidbody2d, it starts to fall horizontally, and my up button on the joystick doesnt work, like gravity is against it... i set the mass to 1, but still falls, i copied everything i could on your video, but still keeps falling, what else should i check for?
@brianmo26115 жыл бұрын
Any way you could show how to make a block where the player has to "press a key" to activate a pushing mode allowing them to push the block one way or to pull it the other way. and when they press the button again they just walk normally around/next to said block
@CodeMonkeyUnity5 жыл бұрын
You could limit the players movement and reduce the objects mass, when he presses the button again set the mass back to a massive number.
@Semaj0z4 жыл бұрын
u could add a rigidbody to both payer and block, then add the iskinemtic thing ot the block, they remove it wen u press a button
@spaceeggmc19383 жыл бұрын
code monkey: " as you can see very basic coding very simple movement" me: " yeah maybe for you that coding is far from my brain being able to comprehend that"
@omidnajmi6019 Жыл бұрын
thank u man, u solved my problem
@CodeMonkeyUnity Жыл бұрын
I'm glad the video helped! Thanks!
@KerasinafLega6 ай бұрын
Hi! thanks for the vid, its awesome and really helped me on undersatding colissions better! i have a question, if i want a multiple triggers to cause a different events how can i do that?
@CodeMonkeyUnity6 ай бұрын
Make multiple separate game objects each with its own trigger and script
@Steve-gi2yj3 жыл бұрын
thank you for the tutorial, do I need to use RigidBody2d to make it stop against walls? right now i am using a joystick prefab, and in the code using: player.transform.position, and I set an object, just a black cube, with only box collider 2d, and the player still goes through it... so again, is it because I am using transform.position instead of Rigidbody2d? I set everything you did at the 5:51 video mark.... but not working.
@CodeMonkeyUnity3 жыл бұрын
The rigidbody by itself has no shape, the shape is on the collider. So just a rigidbody will move through walls If you manually set the transform.posiiton then you're overriding the rigidbody logic (unless you make it kinematic but then you have to handle collisions yourself)
@pradhyumansolanki65098 ай бұрын
broooooooooooooooooooo,thank my gooooooooooooooooood,really i mean it you are an absoulte lifesaver
@CodeMonkeyUnity8 ай бұрын
I'm glad the video helped you!
@definitelynotjames19705 жыл бұрын
I just got your own advertisement from this video
@upsidegaming71342 жыл бұрын
Sorry if this is a silly question, I’m new to Unity and don't quite understand how to detect when two specific objects collide instead of any collisions detected.
@CodeMonkeyUnity2 жыл бұрын
The script that has the physics function will run when that object is involved in a collision. So you know that object is one of the two objects involved in the collision, for the other one, perhaps you identify it by a direct reference (collider.transform == testTransform), perhaps the other object has some identifying component collider.GetComponent() != null; etc
@baisk71054 жыл бұрын
you literlly safed my life
@phin-7261 Жыл бұрын
very helpful. just one problem that light bright coding screen is killing my eyes.
@CodeMonkeyUnity Жыл бұрын
Sorry but dark mode burns my eyes
@rollingstonesonroad4 жыл бұрын
Hello. I am trying to detect on trigger condition with prefabs. But the problem is it is detecting the collision with only the first prefab out of the spawning prefabs. How to rectify this?
@cate01a2 жыл бұрын
cheers! my issue was using OnTriggerEnter instead of OnTriggerEnter2D :)
@d3zar3 жыл бұрын
uhmm, i have a polygon collider. I'm trying on triggerstay2D event for this. But uh If i wait with dummy mode ( so doing nothing ) in my polygon collider it's working for 2 seconds. But after debug.log is not logging while when i out from dummy mode. Why it's stopping working .? And how can i do like your heal circle in this video.
@DWIWindsands2 жыл бұрын
Nice I can use that on my bullet & it won't stick to the wall or I can not & make it stick to the wall TY.
@loya53773 жыл бұрын
Hi! Please help me! How can I determine the coordinates of the vertices of the Box Collider? If the object's rotation is not (0, 0, 0), then collider.bounds doesn't help.
@peachytunes41933 жыл бұрын
I spent two hours trying to figure why my trigger wasn’t working just to realize that the problem was I typed collider instead of 2D collider
@pmoneyish68693 жыл бұрын
And here is the comment that just saved me :). Thanks!
@chilyphilly2 жыл бұрын
OMG i love you! I had that same issue until i tried this.
@burakyigitgulsun3833 Жыл бұрын
I'm using ontriggerenter 2 and ontriggerexit2d to check if my character is inside a cave. but since my character's collider is smaller than the collider of the cave, the oncolliderexit2d command works as soon as I enter the door as if I went out of the cave, how can I fix this?