0 votes

I have a 3d project and I want to create a point on the screen so that it detects when it is over an object and catch it.
How do I do this and what nodes do I need?

in Engine by (195 points)

1 Answer

+1 vote

you need raycast!

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 (collidewithareas) and/or PhysicsBodys (collidewithbodies).

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 iscolliding( ) ... get the collider with getcollider( )

have fun!


by (4,078 points)

I could do it with the body entered signal of an area to detect when there is something over this?

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!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.