How to make scene disapear when going/gone through other scene

Godot Version

4.3

Question

I am making a simple 2d game where a user has to run through a room that has cameras in it rotating, if they get caught by the camera then they lose. What I am trying to do is limit my camera “view” (when I say camera and view here I am talking about an area2D with sprites and a CollisionPolygon, the view is how I imagine what the camera is able to see) so that when it hits a wall it doesn’t clip through the wall with the collision object.

I have attached an image which I hope shows what my thought is, basically in my current context a camera can look at a wall and the collision object will go through the wall and “catch” people on the other side, whereas in real life people can’t be seen on the other side of a wall.

I believe I could have my setup of the scene done incorrectly, I only just started yesterday and I cant find much information on this sort of setup. My “camera” scene is an Area2D with Sprites for the “camera” and the “view”


And my walls are a StaticBody2D with sprites

Many thanks

Why not use an Area2D/ShapeCast2D, detect if the player is in the area, and then cast a RayCast2D from the camera to the player? By using RayCast2D’s get_collider() function it only returns the first object it hits, meaning if it hits a wall first then nothing happens, but if it hits the player directly then your “caught” logic ensues. This won’t clip the excess camera detection areas, but functionally would only allow for direct camera-to-player detection.

1 Like