- Home /
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
So did you parent the collider to a transform tree with a rigidbody in it? And what is it failing to collide with?
Still waiting for some documentation regarding this issue... Unity should warn the users about what happened and how to proceed. $$anonymous$$y project broke and I have something about 2 weeks to deploy my application and everything regarding this trigger stopped working. I had to revert the whole thing to 3.1... I paid for the Pro version, I should have the program updated but I can't, and it's not my falt.
Answer by Dinart Filho 1 · Feb 17, 2011 at 03:57 AM
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.
Thanks for the possible solution, I'll keep that in $$anonymous$$d for the future. The project I was busy on had such a tight deadline that I decided to downgrade eventually.
Answer by jonas-echterhoff · Feb 14, 2011 at 08:17 AM
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.
Answer by Teragram · Feb 11, 2011 at 09:07 PM
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 question as for OP: So did you parent the collider to a transform tree with a rigidbody in it? And what is it failing to collide with?
Answer by Dinart Filho 1 · Feb 13, 2011 at 01:59 AM
Same problem here, I am downgrading right now.
No UnTriggerStay, no UnTriggerEnter and no UnTriggerExit
Same question as for OP: So did you parent the collider to a transform tree with a rigidbody in it? And what is it failing to collide with?
Answer by Dreamora 1 · Feb 13, 2011 at 07:57 PM
didn't have any problem with ontrigger stay on my iPad project nor the desktop project