How to detect if object was escaped form the screen?

@xdzielony

I wouldn’t use that…
I think in editor it check all the cameras, which might be problematic.
And you shouldn’t probably do GetComponent in every Update… cache that to some field.


Also - when posting code, always use code tags, here is how:

You can edit you message with that edit button…


I would use this instead:

screenPos = myCamera.WorldToViewportPoint(transform.position);

Then simply check if your position is less than 0 or more than 1 in either x or y.