A RayCast represents a line from its origin to its destination position, cast_to. It is used to query the 3D space in order to find the closest object along the path of the ray.
RayCast can be configured to report collisions with Areas (collide_with_areas) and/or PhysicsBodys (collide_with_bodies).
Create a StaticBody under that create a CollisionShape. Set the CollisionShapes Shape. Best put your geometry in the StaticBody or CollisionShape container your just created.
Create a RayCast and put it under your camera. Do you see the faint white line? This is the ray that checks for collisions. Write a script … check RayCast for is_colliding( ) … get the collider with get_collider( )
I could do it with the body entered signal of an area to detect when there is something over this?
lalel345 | 2020-08-18 17:21
i dont understand your question. Surely you can do it with areas too. But i suggested to use raycast.
You could put an area under your camera and check this for collisions. But i would prefer raycast. This would although take sight blocking elements into account.
Try it and choose the method that suits your needs!