Version 3.2 gives no OnTriggerExit when collider is parented

Hi,

I'm now having a problem in my game since the upgrade to 3.2: in my elevator algorithm I parent my player to the elevator gameobject in the OnTriggerEnter function. But when this has happened, I don't receive an OnTriggerStay, nor an OnTriggerExit call anymore.

Is this normal behaviour since the update, and if so, what is the best way to solve my problem? Since I unparent my player in the OnTriggerExit call, but now I don't get that call anymore at all!

Thanks in advance, Lieven

One change in 3.2 which might affect this is the following bug fix:

Parenting a collider to a rigidbody at runtime will now correctly add it to the rigidbody.

In previous Unity versions, parenting colliders to rigidbodies at runtime did not properly attach them, so the result would be different then when parenting while editing. Without having an example project of what exactly has changed for you, it's hard to tell if this is the actual issue, and what would be the best way to work around it, though.

Since I upgraded to 3.2 I am having the same problem with my elevator un-parenting. Even the Debug.log does not return anything to the console when function OnTriggerExit is called. Is this a bug? It was working perfectly before the 3.2 update. Anyone has a fix?

Same problem here, I am downgrading right now.

No UnTriggerStay, no UnTriggerEnter and no UnTriggerExit

didn't have any problem with ontrigger stay on my iPad project nor the desktop project

One of my multiple failure scripts in this new version was this simple one:

//=====================================

var working = false;

function Update(){

}

function OnTriggerEnter (other : Collider){

if(gameObject.tag == "objeto" && other.gameObject.tag =="Player"){
gameObject.tag = "objetocomum";

renderer.material.color = Color.red;
working = false;
}

if(gameObject.tag == "switchOn" && other.gameObject.tag =="Player"){
gameObject.tag = "objeto";
renderer.material.color = Color.blue;
working = true;
}
}

function OnTriggerExit (other : Collider){
if(gameObject.tag == "objetocomum" && other.gameObject.tag =="Player"){
gameObject.tag = "switchOn";
renderer.material.color = Color.blue;
working = true;
}
if(gameObject.tag == "objeto" && other.gameObject.tag =="Player"){
gameObject.tag = "objetocomum";
renderer.material.color = Color.red;
working = false;
}
}

//==========================================

it is added to a trigger box, son of another thing. Works well on 3.1 version but in 3.2 simply doesnt work.

It just changes the color, the tag and says that something is working or not, very simple, you can try it too.

Same problem here!!! OnTriggerExit does not work any more if the collider is parented.

I think I found something, In my project the problem isnt about be parent or not, In my project my main character has 3 scripts added to him, are:

1 - the character mover 2 - the character Damage 3 - the character Animator 4 - another one to aditional commands such as getting in vehicles, turn on or of the first script, get in platforms, etc.

If I turn of the 4th script, everything. This simple thing gives me multiple problems :/

I will try to put everything in the same script.

I found a "band aid" solution, is to "force" the "ontriggerexit"

how so?

you can make the Update function check if it is still colliding and use just the "OnTriggerStay" function instead "OnTriggerEnter and OnTriggerExit" so my solution was to make the script deny every 0.2 seconds if it is still triggering.

in my exemple when the object.tag is "platform" the playerscript parent the player to the object with "platform" tag so the "onTriggerExit" doesnt work anymore and the character cannot be free from the platform, thats my solution.

Exemple here:

//======================================================

var accept = false;

function Update(){

if(!accept){

gameObject.tag = "objetocomum";
print("untagged");
}

if(accept){
gameObject.tag = "platform";
accepted();

}
}
function OnTriggerEnter (other : Collider){
if(other.gameObject.tag =="Player" ){
accept = true;
}
}

function accepted(){

print("tagged");
yield WaitForSeconds (0.2);
accept = false;
}

//======================================================

I used the "print" to be sure that it was working, dont forget to add some tags to make it work.

It isnt the solution but is a good way to keep developing on 3.2 before they dont give us a final solution.

and

Sorry to make your question a monologue, I hope it help you.

I've got the same problem unfortunately. I parented the collider to a transform tree with no Rigidbody, but the object that is entering the trigger does have a rigidbody. It's basically a character walking onto a platform with a trigger on it. When you walk into the trigger, the player (rigidbody) should be parented to the platform. This worked fine in Unity 3.1 but no longer works in Unity 3.2+. No errors are given, but the OnTriggerExit function is never fired. Any word on this?

Try out this script I made, I was having the same problem with the conversion, it worked fine here.

public class Parentesco : MonoBehaviour

{

private bool alguemEntrou = false;

void Start()
{
}

void Update()
{
}

void OnTriggerEnter(Collider entrou)
{
    if (!alguemEntrou)
    {
        entrou.transform.parent = gameObject.transform;
        alguemEntrou = true;
    }
}

void OnTriggerExit(Collider saiu)
{
    alguemEntrou = false;
    saiu.transform.parent = null;
}

}

I hope it helps, good luck!

Remedio

Does anyone know where I can download 3.1?

I was having the problem that the OnTriggerExit was not being executed, not even the OnColliderExit in the collider marked as “is Trigger”, but watching the documentation, the method has this note:

This message is sent to the trigger and the collider that touches the trigger. Note that trigger events are only sent if one of the colliders also has a rigidbody attached.

So what I did has attach to my object a rigidbody, and start to work. I don’t know if this is part of the problem, but in the same object I have three colliders as children of the object with the CharacterController, and the collider as “is Trigger” detects the collision with the other objects.