A very strong / heavy rigidbody like kinematic but not

Hi,

I’m looking to put a game object into a sort of “super” mode. In this mode other rigidbody-colliders bounce off the “super” rigidbody-collider without affecting its course.

However the “super” rigidbody-collider still needs to be controlled by ApplyForce of its own based on the player input. I don’t want to switch it to non-physics movement because then I will have two parallel movement systems which will need to be in sync in terms of feel.

So basically what I am looking for is similar to a kinematic rigidbody-collider, but the only problem is that the kinematic flags screws up the ApplyForce() based movement code. I’d like the physics simulation to move the object based on ApplyForce(), but during collisions it should behave like a kinematic body and be “immune” to collisions but still affect the bodies that collide with it in the normal way.

The only way I was able to achieve this was by using two game objects that are not directly related through their transform (i.e neither one is a child of the other), I set the collision between them to ignore, and then I use ApplyForce() to drive one of them (the original), and the other one I keep setting its position and velocity to that of the original.

This works but it’s somewhat hacky. I was wondering if there is a better to do it?

It looks like the answer is “no”. So for anyone who comes across this with a similar problem, here is some pseudo-code illustrating the way I did it:

private GameObject superShield;

public void GoSuper()
{
    collider.enabled = false;
    superShield = new GameObject();
    superShield.AddComponent<SphereCollider>().radius = 5;
    superShield.AddComponent<RigidBody>();
    superShield.rigidbody.mass = 5000;
    // Any other rigid body settings applicable to your game.
}

public void FixedUpdate()
{
    if (superShield != null)
    {
        superShield.transform.position = transform.position;
        superShield.rigidbody.velocity = rigidbody.velocity;
    }
}

public void StopSuper()
{
    collider.enabled = true;
    Destroy(superShield);
    superShield = null;
}

Basically the key is to break the relationship between the “super shield” collider and the player’s rigidbody so that collisions with the “super shield” don’t affect the player’s physics. This is achieved by having them on two completely separate game objects. Then the super shield is manually made to follow the player in the traditional manner of setting its position each frame. Its velocity is also set to that of the player each turn eventhough that won’t have an effect on its own movement, but it will make the effect of its collisions on other game objects appear more natural.