Ray being cast from disabled camera

I’m running into a very weird issue, I have two cameras in my scene related to it, one is the main scene camera which gives this view:


The second is just in front of the screen on the left side, giving this view;

When the player enables and switches over to the second, the main scene camera is disabled. The issue is that raycasts appear to be originating from the disabled main scene camera, rather than the newly enabled second camera despite the origin being updated in code which is preventing interaction with the arrow & close buttons in screenshot 2 while allowing interaction with the scene as if you were viewing it from the main camera.

Has anybody ran into a bug like this before?

Can you post your raycasting code?

I’d guess you’re using Camera.main in your raycast code, but the camera you switch to doesn’t have the main camera tag.

Hard to say without code though :slight_smile:

I think I have that angle covered, casting using a camera variable and updating to that each time a switch is made, see below.
7480259--919862--upload_2021-9-8_10-35-8.png

Even if I had been using Camera.main, wouldn’t it update to the current enabled camera however? Both cameras have the main camera tag.

Yeah, I was just speculating. Not the problem if you’re not using Camera.main.

Can we see the script where your currentCam is changed?

Nothing offending here either
7481045--919973--upload_2021-9-8_15-50-22.png

Resolved with a bodge job :@