• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by klolololol · Apr 09, 2015 at 04:26 AM · collider2doncollisionenterintersectoncollisionexitcollosion

Track all colliding Collider2D.

I want to keep track of all Collider2D what is touching my player.

I used: OnCollosionEnter/Exit2D with a List but it just fails to remove some Colliders.

     void OnCollisionEnter2D(Collision2D coll) {
         collidingTiles.Add(coll.transform);
     }
 
     void OnCollisionExit2D(Collision2D coll) {
         collidingTiles.Remove(coll.transform);
     }

I saw someone using the intersection of the renderer's bounds, but I think it's not the appropriate way. Is there a solution for this?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by klolololol · Apr 10, 2015 at 12:32 PM

Eventually I used this function to solve the problem in my Player's FixedUpdate method.

 Physics2D.OverlapCircleAll(player.transform.position, playerCollider.radius, 1 << LayerMask.NameToLayer("Ignore Raycast"));
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

OnCollisionStay2D not working in the way I would like. 1 Answer

[2D]Collider corners problem 1 Answer

Object Reference Not Set 2 Answers

Check if an Object is going to overlap another (2D) 2 Answers

Can't specify OnTriggerStay2D to gameobject/gameobject not responding? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges