Sphere collider with "isTrigger" affecting collisi

So I haven’t found a solution in any similar threads.

I use a sphere collider with “isTrigger” set to true so I can test to see if something enters it.
Once something does, I destroy the volume.

On the object (the root parent) there is a box collider that I use for movement.

When I remove the sphere collider from the child (who is still “isTrigger = true”, the whole object just falls through the ground. I would have thought that the box collider would still be valid, and it would ignore the loss of the sphere.

There is only one rigidbody on the root parent, not on the child with the sphere volume.

FYI: The sphere collider completely overlaps/encompasses the box collider (and even penetrates the ground).

Any ideas?

Make sure the object that is falling incorrectly has set the rigidBody isKinematic flag to TRUE. Then gravity won’t affect it.

This is more of a Support or Scripting forum type of post.

Yeah- that’s why I posted in the scripting forum. :wink:

Unfortunately setting my rigidbody to be unaffected by gravity wouldn’t work, as it’s needed for my movement.

Besides,it seems odd to me that a collider, flagged as a trigger, without a rigidbody would affect the rigidbody on the parent ONLY when removed (or the radius is changed).

hrmm…

Can you post the code you are using to remove the collider? Adding or removing colliders at runtime doesn’t always work as you might expect.

Wow, came to post exactly the same issue. I’ve thrown everything imaginable at it but this issue persists very badly.

Is there no way you can have isTrigger active with a radius around the object with a Rigidbody attached and it didn’t fall right through the ground?

I was creating the collider at run time to find out who was near me to choose a new attack target. I never got the collider to work without having the object fall through the geo.

Ultimately I scrapped that idea when I found “Physics.OverlapSphere”. From there I deduce the next logical target from the returned array.

This is a better solution, so I’m not complaining, but I never got the other way to work.

Sry.

Damn. :frowning:

Really badly need it to have a radius proximity like trigger.

Just curious though, why does it kill the Rigidbody when isTrigger has been ticked?

No clue. Its been a while since I had to face that problem.

gl.

Thanks, hopefully something will popup :slight_smile:

Found a solutions for this problem, not exactly pretty but it does the job well!

private var isTriggered : boolean = false;
private var triggerCount : int = 0;
private var playerDistance : int;
var user : GameObject;

function Update() {
playerDistance = Vector3.Distance(transform.position, user.transform.position);
	if(playerDistance < 12.0)
	{
		if (triggerCount != 1) {
			print("triggered");
			isTriggered = true;
			triggerCount++;
		}
    } else {
		if (triggerCount != 0) {
			print("trigger exit");
			isTriggered = false;
			triggerCount--;
		}
	}
}

What the above code, as you may have guessed, does is it checks the distance between the player and the object. This way you can have the Rigidbody physics on it without it going through the ground :slight_smile: