- Home /
Manage multiple collider2d
For my runner game I have attached two colliders to my main player as per following image represent :
Following image represent inspector window :
At present all the collision and trigger enter methods called for two time because of 2 colliders. I have also tried with putting this type of condition but in output it always return circle collider if I collide with box collider also.
if(collider2D.GetType() == typeof(BoxCollider2D))
Debug.Log("box collider");
if(collider2D.GetType() == typeof(CircleCollider2D))
Debug.Log("circle collider");
I just want single time collision event or division between colliders. Please give some suggestions in this.
Collider2D is a reference to the first one in the list of components on your game object. Switch their place and the other one will constantly trigger. The collision struct you receive on collision includes contact points, which differentiate between collider and othercollider. Check collider here and you'll get the correct result
@hexagonius, thanks for your reply. I want to handle OnTriggerEnter and OnCollisionEnter methods for player object. So no contact points exist in OnTriggerEnter method.
Then you'll need to have each collider on it's own gameobject with its own rigidbody with their own scripts.
In that I can't able to create capsule like collider using hand movement. $$anonymous$$eans smooth curve.
Answer by epox277 · Mar 20, 2015 at 11:07 PM
create a prefab with empty objects, attach colliders on it and use them separately in script like arm, leg or something.
Your answer
![](https://koobas.hobune.stream/wayback/20220613190630im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Joint2D Tutorials 1 Answer
2D Physics and Jump-Through Platforms 2 Answers
Get Width of 2d Game Object 1 Answer
How can I make 2d sprites for Unity ? 1 Answer
Refreshing the Polygon Collider (2D) upon sprite change? 1 Answer