Play 7 Awesome Games and help support the channel! (Action, Strategy, Management) Get the Game Bundle at unitycodemonkey.com/gameBundle.php See what I'm teaching here applied to real games!
@the_naacho0974 жыл бұрын
hello code monkey !! I wanted to ask you that as I download the project I am going to download it, I open it and I get an error? I don't know if I'm doing it wrong but I would like you to explain how I downloaded it to see your videos! or if you don't pass me the same project for mega that already there will be downloaded kzfaq.info/get/bejne/ZrplmMxqz7SaY4E.html
@TalkingRaven_2 жыл бұрын
It's 2021 and THANK YOU for explaining bitmask and the operators clearly and concisely. I got everything that I wanted to learn at 9:00 - 11:00
@waqasgamedev4 жыл бұрын
You are excellent at teaching! You explain basics and behind the scenes so nicely. Keep it up.
@CodeMonkeyUnity4 жыл бұрын
Thanks! I'm glad you like it!
@anormalguy84073 жыл бұрын
trying to search for a collision layers tutorials on KZfaq was pretty frustrating because every video recommended to me was just talking about collisions in general. I am happy i found this one, it's saved me allot of headache :D
@SmellGrow Жыл бұрын
Thanks so much for teaching layers a lot easier for me 2:55
@CodeMonkeyUnity Жыл бұрын
I'm glad the video helped!
@siltoruz35022 жыл бұрын
Thank you so much for this ... I am studying for the professional programer certification and layermasks with bitwise operators was a subject that i could not understand well from other tutorials. This was very easy to grasp and at last i feel i know how to work with those.
@CodeMonkeyUnity2 жыл бұрын
I'm glad the video helped you!
@novaplum16174 жыл бұрын
Fantastic explanation. Some of your code is a way out of my knowledge base as I'm only a beginner, hobbyist programmer but this explained what I needed to know perfectly. Also you showed implementation by writing out examples; that really helped.
@MosphereMusic4 жыл бұрын
Great tutorial, thank you for continuing to share you knowledge
@flemishgiant173511 ай бұрын
Concise and with quick demos.
@Disthron4 жыл бұрын
Layer masks might be easy to work with in regards to ray casts but I just spent the better part of a day trying to get one to work in a simple if statement. I wanted to check if an object was on one of a few layers that were selected in the Layer Mask drop-down menu in the inspector.
@mauriciopartnoy2789 Жыл бұрын
Your examples for bitwise operators were very didactic. Thanks man! :)
@arish72314 жыл бұрын
please continue making such amazing content
@rafaaccr2 жыл бұрын
🤯🤯🤯🤯 Awesome as always! Thank you so mutch for sharing!!
@datboijoshki8833 Жыл бұрын
I love you so much code monkey, this video really helped, I was at the verge of giving up
@x364 Жыл бұрын
This just saved me A LOT of time. Thank you!
@jean-michel.houbre4 жыл бұрын
Exciting and very informative video. The sound was good at home. Only downside: your little ads at the bottom of the screen annoy me (a little) to read the subtitles. But I will come back :)
@LaraSilvestris3 жыл бұрын
Thank you so much! I was having problems with Raycast (enemy should only look for player's collider but it checked every other collider too) but thanks to your explanation, I managed to get it work with layermask!
@jake_mouse2 жыл бұрын
This is exactly what I needed! Thank you Code Monkey!
@BingoGo2Space4 ай бұрын
You are the best at what you do.
@CodeMonkeyUnity4 ай бұрын
I'm glad you find my videos helpful! Best of luck with your games!
@srMorozoff2 жыл бұрын
Crystal clear explanation. Thanks!
@YamiBakuraT3M03 жыл бұрын
Thank you soooo much!! This was exactly what I needed, now I can change collisions from the script thanks to the bitmask!!
@etopowertwon4 жыл бұрын
Sweet, I didn't know LayerMask had its own custom editor in SerializedFields. Personally I usually have static classes with constants and one of such class holds names of all layers, so I can do LayerMask.NameToLayer(Consts.LayerNames.Debris) somewhere in Awake(). It just feels very nice when IDE autocompletes layer name for you. (I don't like that it deals with strings, but sometimes man gotta forgive himself)
@CodeMonkeyUnity4 жыл бұрын
Yup having a static class with the names preset is excellent. Working with strings does suck but if you always use the constants then it shouldn't be a problem.
@himanshugupta3252 жыл бұрын
Very good video on layermasks.
@cristiano48264 жыл бұрын
I saw you on Brackeys insta story❤️. By the way it's too late to comment😅
@ultmatepotato2 жыл бұрын
Sweet! I diddnt know you can stop certain layers from interacting!!! Now i can make it so my player can walk throw the ragdoll corpses of other enemies!!!!!
@mone93662 жыл бұрын
Again, thank you for this tutorial! Your videos are well explained and really helpful!
@jackwilson42163 жыл бұрын
This helped me. Thank you!
@teemuleppa33474 жыл бұрын
Awesome video as always
@aggressivemastery4 жыл бұрын
Awesome detail! Thank you :)
@vikramkumar-lk9me3 жыл бұрын
Great tutorial!! Can you please make a series on how everything in Unity2D template project (platformer) works.
@MathsPlusGames4 жыл бұрын
I love you!
@third3rd7273 жыл бұрын
thank you, this was very helpful!
@ryanmoulla24094 жыл бұрын
I didn’t knew that I could use the layer mask to shoot like this but can we use the layer mask to make enemies following me but not going on environnement?
@CodeMonkeyUnity4 жыл бұрын
What do you mean by not going on environment? To follow the player you don't really need layers, just pass in the player reference to the enemies
@SatishBajagain Жыл бұрын
Best tutorial ever!!!
@DoomCatcher Жыл бұрын
I dont know if id have ever gotten this if I didnt see your visual demonstration of the debug og representing the layers.
@CodeMonkeyUnity Жыл бұрын
I'm glad the video helped!
@SMT-ks8yp2 жыл бұрын
So I can just set some static integers to use everywhere when I need to get certain layers? Like one mask for everything walkable, one for everything attackable by the player, one for attackable and walkable, and so on.
@CodeMonkeyUnity2 жыл бұрын
Sure, or better yet make them consts since they should never change
@SMT-ks8yp2 жыл бұрын
@@CodeMonkeyUnity cool. But can I initialize them through expressions then? Manually typing all the bits for each feels quite error-prone. Or are there another ways?
@marcusferron3 жыл бұрын
What a great tutorial Thank you!
@TheUncutAngel2 жыл бұрын
you. are. a. GOD!!! :D
@blade6612 жыл бұрын
6:50 How is the layer mask ignoring the debris without any code? All you did was declare a layer mask variable. Is there nothing we need to do with the raycast function?
@entertainmentoverloaded57002 жыл бұрын
Awesome..THank you :D
@aadityakiran_s2 жыл бұрын
Excellent video. What's the use of using the binary method if the enum for LayerMask is visible outside? Also isn't it more readable and user friendly if one were to use GetLayerMask("Name") ?
@jihunjang66843 жыл бұрын
Awesome. Thank you!
@synchaoz2 жыл бұрын
Is there a noticeable performance difference between LayerMask and Bitshift when doing expensive operations like raycasting in Update()? Thanks a ton for the vid. I came here to better understand Bitshift, and you definitely made it easy to grasp.
@CodeMonkeyUnity2 жыл бұрын
If you're concerned about performance you can just define the layer with bitshift in a variable, that way the calculation is only done once just like LayerMask I'm glad you liked the video! Thanks!
@018FLP2 жыл бұрын
The tutorial is amazing, thanks for sharing! I never understood Bitmask because i was too scared, as everybody said it involves lots of calculations, and you explained in such and easy way that now i feel like i got it! Also, could you give me an insight about some code? To contextualize: First, i detect with a collider trigger the reacheable area, then if there is something with the tag "solid" in the way, i shoot a Raycast. if the Raycast hits a Rollable layered object, then i set a animation bool to on, to enable a pushing animation. The problem is that it simply does not work. It's always "NO ROLL". The object is marked correctly, and the layermask is too, and the debug show it works as no roll when hitting any surface, including the one i'm trying to get. Also, it don't display any error. private void OnTriggerStay(Collider other) { if (other.CompareTag("Solid")) { Player_Animator.SetBool("FrontDetected", true); Physics.Raycast(transform.position, transform.forward, out HitFront, maxDistance); Debug.DrawRay(transform.position, transform.forward * maxDistance, Color.red); if (HitFront.transform != null && HitFront.transform.gameObject.layer == Rollable) { Player_Animator.SetBool("Roll", true); Debug.Log("Roll"); } if (HitFront.transform != null && HitFront.transform.gameObject.layer != Rollable) { Player_Animator.SetBool("Roll", false); Debug.Log("NO ROLL"); } }}
@CodeMonkeyUnity2 жыл бұрын
Use Debug.Log to see what you're colliding with, HitFront.transform You said your first hitting a collider trigger? Then it's likely that object that you're hitting
@018FLP2 жыл бұрын
@@CodeMonkeyUnity Thank you very much for the answer! I solved it changing to (...) if (HitFront.transform != null && HitFront.transform.gameObject.layer == LayerMask.NameToLayer("Rollable")) { Player_Animator.SetBool("Roll", true); } The collider was okay, it seens the layer identify code what was not the best! Thanks again for taking your time, this tuto helped me very much, you rock!
@3Katapa2 жыл бұрын
If I understand correctly, I can use layers to keep Colliders I use as triggers from interacting from each other, correct?
@CodeMonkeyUnity2 жыл бұрын
Yes you can use layers and the collision matrix to handle that, or just do some kind of verification on the other object when you enter a trigger
@workthenplay Жыл бұрын
Thank you!!
@arish72314 жыл бұрын
luv your content bro
@bhupiistersingh40974 жыл бұрын
great tutorial thanks...
@jasonbaldwin2733 жыл бұрын
Is there a reason why you can't just refer to the Layers via a simple int? The Bitmasking is cook, but it seems overly complicated.... But I don't really know what I am talking about :D
@CodeMonkeyUnity3 жыл бұрын
It's for performance and memory reasons. Instead of having 32 ints wasting 32*32=1024 bits, the engine uses a single int to store all 32 layers.
@jasonbaldwin2733 жыл бұрын
@@CodeMonkeyUnity That makes sense! Thanks for the quick reply :)
@zodix443 жыл бұрын
Thank you
@cristiano48264 жыл бұрын
Informative☺️
@Jordan_ThirdPersonShooter Жыл бұрын
Hi code monkey i would like to know how to change base layer weight to 0 and thank you
@rainalo2 жыл бұрын
is it possible to add an extra layer between 2 layers? maybe move them?
@CodeMonkeyUnity2 жыл бұрын
Nope, layers are bits so you can't reorder them. The only way is manually, go into the layers and change the name of two layers you want to "swap" then change all logic where you use those layers.
@hakanviajando25 күн бұрын
Thanks a lot
@totuk0013 жыл бұрын
God, [SerializeField] private LayerMask groundLayerMask; won't bring up the layermask option for me in the editor and I can't figure out why
@CodeMonkeyUnity3 жыл бұрын
That's odd, does it show up if you make it public?
@totuk0013 жыл бұрын
@@CodeMonkeyUnity Nope! Created a brand new object, thinking my code might have messed something up, but on a completely new and empty player object, the [SerializeField] and the public LayerMask option just doesn't create that option for me in the editor, and couldn't figure out why so far :/
@CodeMonkeyUnity3 жыл бұрын
@@totuk001 What Unity version are you using? Does it recognize the type?
@ibrahimrashwan4 жыл бұрын
How can I set up an ignore layer mask?! I want to check for ground against all collides except the ones with the ignore layer . I know that I can check for ground against all the colliders with (the ground layer for example) I just need this specific behaviour .
@CodeMonkeyUnity4 жыл бұрын
The layer mask builds the underlying bitmask. If you want to ignore a particular layer then just select all others except that one.
@finn800x58 күн бұрын
nice👌
@s1s1l1sko7 ай бұрын
you didnt show writing layermask in the raycast
@CodeMonkeyUnity7 ай бұрын
It's the last parameter
@MrADELx184 жыл бұрын
Can you make tutorial with godot engine?
@CodeMonkeyUnity4 жыл бұрын
I'm really focused on Unity so no don't have the time to explore a different game engine.
@egesaglam55984 жыл бұрын
hello
@kaderkader17714 жыл бұрын
how to make left, right and jump buttons for android device
@Otawee4 жыл бұрын
So few subs
@CodeMonkeyUnity4 жыл бұрын
If you like the video, subscribe!
@theDarkerSan4 жыл бұрын
first
@BlueBirdgg4 жыл бұрын
You need to buy a better microphone or increase the volume of your videos...
@CodeMonkeyUnity4 жыл бұрын
Really? Are you sure you don't have your computer sound turned down? It's pretty loud to me at just 40% volume.
@BlueBirdgg4 жыл бұрын
@@CodeMonkeyUnity The volume of your videos is quite lower than the average of KZfaq videos and other internet stuff...
@FateEpsylon4 жыл бұрын
Sounds perfectly fine to me and I regularly keep my volume around 20%... His mic/volume is fine.
@SDB_Dev4 жыл бұрын
Personally I have to keep the youtube volume mixer down at about 30% on these videos whilst having my headphones set to 20% volume to avoid damaging my ears lol. Please do not increase the volume even more.
@LazyGuyMemes5 ай бұрын
What's the actual difference between Physics.Raycast() and PhysicsRaycaster.Raycast()?