Weird "bug"

If you both have the scene and game window open and the scene window shows the enemy, then

if (!target.GetComponentInChildren().isVisible)
{
continue;
}

does not work. You will still be able to face the enemy which is behind the camera if you press tab despite this code.

How could an open scene window affect the game during runtime?

It’s because the scene view has a camera. If the enemy is visible to a camera, it will report that it is visible. It does - unfortunately - not distinguish the scene view camera from any other cameras. I suppose it’s because there aren’t any scene view cameras in a built game.

Yes, this seems to be the case. This also means that the default unity editor layout should not include both the scene and game view open if you don’t want to run into this kind of issue.

Yes, I’ve run into this issue before as well. You could create a layout identical to the one you’re using but without the Scene view in it, and switch layouts immediately before playing the game.

:+1:

Privacy & Terms