- Home /
How do I get the layer of an object
Im trying to find the layer of a gameobject through a collision with Physics.OverlapSphere, how would I do that?
That function takes a layermask as a parameter so just add the layermask you want to detect into the function.
Physics.OverlapSphere(position, radius, layermask)
Answer by Hawaii_Dev · May 17 at 08:32 AM
resultCollider.gameObject.layer will return the layer your physics.overlapsphere returns. Remember that Physics.OverlapSphere returns an array so you need to map over that array and find the correct gameobject.
Your answer
Follow this Question
Related Questions
Collision detection with overlap sphere 1 Answer
Making a Cubical Collision Check within a function 0 Answers
Detecting how much of a Sphere is overlapped 0 Answers
Detect collider collision ,identify and access colliding colliders 0 Answers
OverlapSphere, check how many object with specific tag did it collide with.. 2 Answers