- Home /
Making Rigidbodies to interact but allow them to go one through the other
In my game I have a Player and many leaves shaken by the wind.
I have activated Colliders and Rigidbodies in both elements so they can interact with other elements.
I am trying the Player to interact with the leaves dragging them a bit but allowing the Player to go through them with minimum resistance.
I know I can play with the Layer Collision Matrix to make the Leaves ignore the Player but I actually want some kind of interaction as explained above.
This is what I have now with the Layer Collision Matrix and the Colliders and the Rigidbodies all activated:
Any suggestion of how can I achieve this? Is there something I can do with the Unity physics or should I have implement this procedurally with code?
Answer by logicandchaos · Jan 25, 2021 at 04:26 PM
Make the collision a trigger then you can use OnTrigger() for your interaction and still be able to pass through them.
Exactly, keep in $$anonymous$$d that you can have multiple colliders as a child of your rigidbody and each collider can be on a different layer.
Yes this is correct . this also is a good way to have different trigger events such as a collision on the right causes one action to happen but hit from behind plays a different animation just as an example
I understand you are suggesting to implement the dragging interaction procedurally into the OnTrigger() implementation. I was wondering if there is any Unity physics I can use so I don't need to program this my self.
Your answer
Follow this Question
Related Questions
Platform Effector 2D with rigidbody2D 0 Answers
Collider2D.GetContacts(List() contacts) works with OnColliderEnter2D but not with OnTriggerEnter2D 1 Answer
Scaling colliders up and down over time 1 Answer
Moving colliders that are part of a composite collider 1 Answer
2d rigidbody falling from the collider when it is moved 3 Answers