0
Not a bug

Sensor.cs - Problem in OnTriggerExit

Andreas vor 3 Tagen in realvirtual.io Starter and Professional aktualisiert von Support vor 2 Tagen 1

Hello realvirtual team,

on working with the sensor component I encountered an issue in the OnTriggerExit event.

I use the sensor event "EventExit" to trigger logic in my own scripts.

In my application I have a sensor on a MU and this MU stands on a conveyor.

When the MU leaves the conveyor I want to invoke an event in a seperate script.

Image 1255


The problem is that the conveyor is not a MU and therefore "muobj" is null. This is correct.

But because of that the statement "if (thismuobj == muobj)" gets true (both is "null") and the EventExit is not getting invoked. 

I am not exactly sure why the foreach statement is necessary.

I changed the codeline 398 to this: (so the EventExit is getting invoked)

Image 1256

Please check if this change is a problem in other cases. Maybe you can implement it in the next update.

Thank you very much.


Best regards, 

Andreas

Antwort

Antwort
Not a bug

Hello,

the "OnExit" event of the sensor is triggered when a MU exits the sensor. If I understand correctly, you’ve attached the sensor as a component of the MU. In that case, it won’t work as intended.

We won’t be changing this in the release because the for-each loops account for the fact that a single MU can consist of multiple colliders, which the sensor may detect.

I recommend the following approach: place the sensor as a standalone GameObject at the end of your conveyor and use it to trigger your script.

Alternatively, you could use Unity's standard OnCollisionExit method on your own component attached to your MU.

Best regards

Christin


Antwort
Not a bug

Hello,

the "OnExit" event of the sensor is triggered when a MU exits the sensor. If I understand correctly, you’ve attached the sensor as a component of the MU. In that case, it won’t work as intended.

We won’t be changing this in the release because the for-each loops account for the fact that a single MU can consist of multiple colliders, which the sensor may detect.

I recommend the following approach: place the sensor as a standalone GameObject at the end of your conveyor and use it to trigger your script.

Alternatively, you could use Unity's standard OnCollisionExit method on your own component attached to your MU.

Best regards

Christin