checking a gamobjects layer

 function OnCollisionEnter(collision : Collision)
 {
     if (collision.collider.gameObject.layer == LayerMask.NameToLayer("LAYER_NAME"))
     {
          Debug.Log("Touched a rail");
     }
 }

0
0
Awgiedawgie 440215 points

                                    if(gameObject.layer == LayerMask.NameToLayer("LAYER_NAME")){}

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
How to check if you've collides with a layer unity How to check if you've colliden with a layer unity unity check colliders layer unity3d collider check layer unity3d check collider layer collison layer check unity if collide with certain layer unity check collider layer unity how to test for a layer in unity unity get collider layer check object layer unity unity check if gameobject is in layer unitychecklayer of collider check if collision is layer how to tell what layer you collided with on unity get layer gameobject is touching unity check for layer unity unity check collision on certain layer unity 2d check if collider is on layer how to detect collidion with certain layer unity collision layer unity unity oncollisionenter if layer check gameobject for layer unity unity check layer of collider unity check if object in layer unity collidsion layer how to detect when collide with certain layer unity unity check for collision on specific layer unity 2d how to check layer collision how to check collision only on certain layer unity check a layer of object unity unity get layer of collider2D collision.gameObject.layer how to check if somethimg touches a specific layer unity check collision with layer check layer of trigger unity unity check collision layer detect layers in unity how to check if yoyu are touching the defualt layer unity check layer unity unity how to check for layer within area unity check layer how to detect object collision in unity layering unity check layer on collision unity collision layers unity get layer of collider how to get if collided with a specific layer unity if this game object collided layer how to detect if the game object collides whit the layer unity check for collision on layer get layer of collided obj unity detect collision with other layer and what object unity detect collision with other layer how to dectect collison by a layer in unity check if object is on layer unity check if collision hits layermask checking a gamobjects layer how to check what layer an object is on in unity unity check if colliding with layer unity check if colliding object is in certail layer only detect certain layers On Collision only detect certain layers Oncollision unity check for layer layer detection unity check unity collide with layer how to check gameobject layer unity check collider layer
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source