The title might not make much sense, but here is my problem. I have recently started to recreate among us and want the players to ignore collisions with each other. I am now on the kill mechanic and I need the OnTriggerEnter2D function for it to work. Whenever I use Physics2D.IgnoreLayerCollisions() function, the OnTriggerEnter2D function doesn’t work. Is there anyway to disable collision between objects, and keep that function?
You can use layers to determine what can and cannot interact with each other through physics.
Create a player layer and set it so that players cannot collide with other players.
For detecting nearby players with a trigger collider, put the collider on a separate GameObject and give it a different layer that can detect players.
See:
That is what I have been doing but that disables the on triggerenter method
“Disables” how?
OnTriggerEnter2D is just a method. A method can’t be enabled or disabled.
I know it is not disabled, it just doesn’t work when you don’t allow the collisions between layers
You can make ontriggerenter2d on a new child gameobject and assign it a different layer name.
What @Pixitales said.
If you place the collider on a child GameObject with a different layer, collisions should still work.
Thank you, I tried it and it worked!