- Home /
Is there a way to find out what type of collider an object has?
Is there a way to find out what type of collider (box, sphere, mesh) an object has?
I know I can check for each type individually, but I need to dynamically change collider parameters on several different types, so it would be nice to do it in a more generic manner
thanks
Answer by equalsequals · Jul 23, 2010 at 06:51 PM
You can simply ask:
C#
if(collider.GetType() == typeof(MeshCollider)) print("mesh");
And JS
if(collider.GetType() == MeshCollider) print("mesh");
Hope that helps
==
you are missing the point- I already know I can do this by checking against each type as you showed
I would like to be able to have the collider type returned so I don't have to check it against each one individually.
If you look at the code provided GetType() returns the object type.
I only get "Collider2D" but not the specific type of collider (EdgeCollider or CircleCollider)
Your answer
Follow this Question
Related Questions
can i change collider type in run time 1 Answer
Internal collisions 1 Answer
Checking "type" of "Collider" in C# 3 Answers
Set a variable to a collider type. 1 Answer
Fast object on collider not working 1 Answer