Rigidbody Ignore another Rigidbody?

Hello!
So I have an interesting questions- Is it possible and how to make it so 2 rigidbodys Ignore each others physics?

Basically I have rigidbody A and rigidbody B and I want to make it so that they don’t affect each others position. I still want them to collide with each other but I don’t want them to be moved by one another. Yes, I could change the mass of rigidbody A and make it higher but then rigidbody A wouldn’t be affected by rigidbody B but Rigidbody B would still be affected by rigidbody A.

Anyway long story short- How to make 2 rigidbodies ignore each others rigidbodies but still register each others colliders like when a rigidbody hits a rigidbody it acts as the other rigidbody is a collider instead of a rigidbody?

you can check the istrigger component in its collider in inspector by this you can check if they trigger each other and they will not effect its position

Yes. You should be able to write 2 scripts and attach one to each of the objects. It really depends on what you want to happen if the 2 objects do collide. Do you want them to just immediately stop moving? Do you want the objects to be able to pass through each other? What are you wanting to do? If you want them to immediately stop you could do something like this:

Object 1 Script:

void OnCollisionEnter(Collision other)
{
   if(other.gameobject.name == "myFirstGameobject")
   {
      gameObject.rigidbody.velocity = Velocity.zero;
      gameObject.rigidbody.angularVelocity = Velocity.zero;
      // You may also want to use the function:
      // gameObject.rigidbody.Sleep();
   }

then on your second GameObject attach a script like:

    void OnCollisionEnter(Collision other)
    {
       if(other.gameobject.name == "mySecondGameobject")
       {
          gameObject.rigidbody.velocity = Velocity.Zero;
          gameObject.rigidbody.angularVelocity = Velocity.Zero;
          // You may also want to use the function:
          // gameObject.rigidbody.Sleep();
       }

Another good solution (depending on what you are trying to do) may be using the Layer Based Collision. See the Unity Manual to use it. Here is the link to it. Unity - Manual: Layer-based collision detection

Maybe put them in two different layers and use Layer Based Collision Detection: Unity - Manual: Layer-based collision detection

Physics.IgnoreCollision(collider 1, collider 2, true);

or false if you want to revert it.

You can use unity’s built in matrix system that allows you to chose what layers can interact with others.Official Site