Raycast on different script interfering with one another

Hi,
I’m pretty much combining a lot of tutorial script in my scene to test functionnality.

One thing I’m having issue with is the raycast function.
I put the script for detecting entity with physic/collision with a pulse effect on my first camera ( Entity Picking ). I disable the camera 1 and switch to another camera ( More cameras ) that has another raycast function with a different effect ( Point and click movement ).

Except, when I’m in camera 2, it’s still trying to lauch event that were in the script of camera 1 even if it disabled, the pulse script

It looks like the first script adds a listener to ‘this.app…’? That referes to the core playcanvas runtime - it does not automagically remove event listeners added scripts which are then disabled (I believe).

You need to manually remove the listener when the object that attached that listener becomes disabled, i.e. call this.app.off(…)