- Home /
One-Way Collision Between RigidBodies
Example:-
RigidBody_A IS NOT KINETIC
RigidBody_B IS NOT KINETIC
RigidBody_A CAN detect collision with RigidBody_B
RigidBody_B CANNOT detect collision with RigidBody_A
Is this collision possible to setup?
Any help will be greatful thanks!
Answer by Bunny83 · May 03, 2011 at 01:12 PM
Well what you're asking can't be generalized in any way. Actually do you mean physics collision response or do you mean the collision messages? The physics can't be setup that way. If there's a collision it has to be between TWO objects.
To prevent the collision message on one of those two objects i would give object B a referenc to object A, so it can determine when it collides with A.
//JS
var doNotCollideWithThat : GameObject;
function OnCollisionEnter(col : Collision) { if (col.collider.gameObject != doNotCollideWithThat) { // Hey, it's not Object A } }
Answer by Joshua · May 03, 2011 at 01:27 PM
You could have triggerspheres around both of them, and if they are in eachother's triggersphere turn them to kinematic. Then fake the physics.
Answer by Scopperloit · Feb 16, 2013 at 04:28 AM
This depends on what you want to do. You'll have to give some more conditions, because like Bunny83 pointed out, two objects will always collide with eachother, never one object with another.
However, if one of the objects is at rest or have low velocity and the other collides into it with rather high velocity, that is something you could define as one-way collision. Now you can take the objects' velocities into consideration.
You could for example script this scenario:
if RigidBody_A has greater velocity than RigidBody_B then collision is true
else, collision is false.
Answer by Noxury · Jul 23, 2020 at 08:58 PM
If you actually want to affect only one body from impact force (on both NON-Kinematic Rigidbodies), try setting the mass of the uneffected body to 0. This will prevent beeing able to push for object, but stop it.
An example would be physical camera movement. The camera should react to collisions, prevent clipping through objects, but is not allowed to push the player. Instead the player can push the camera away.
Your answer
![](https://koobas.hobune.stream/wayback/20220613131116im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Collisions While Rotating Objects Without Character Controllers 1 Answer
Collisions: do they need two rigidbodies? 2 Answers
what object hit me? easy rigidbody question 1 Answer
Avoid Rigidbody Intersection 1 Answer
Kinematic rigidbodies 1 Answer