Pick up items using raycast

Godot Version



I want to make it so that an item can be picked up by pressing the interaction button

I’d highly suggest you don’t use raycasting as there are better and less potentially demanding ways.

This is a good example:


this is not what I need, I’m trying to do it in 3d from first person. sorry for not specifying

Then you can use Area3D instead. The principles are sound.

1 Like

Okay, I’ll try

Whether to use Area3D or raycasting is going to depend entirely on what you’re trying to achieve, so keep them both in mind as they both have uses for which the other is not well suited.

In the VR version of Seas of Reverence, for example, I use a short raycast emanating from each of the player’s palms to detect which weapon the player intends to select from around his body. While I could use an Area3D in the player’s hands, it would be more likely to select the wrong item when two or more are close together. A raycast is more precise under those circumstances.

There is also nothing stopping you from using both, and enabling/disabling one or both as circumstances warrant.


I somehow wrote a script to select objects using raycast but they either do not appear on the camera or it looks crooked
Снимок экрана 2024-07-05 114205

Try setting the pickup’s local position and it’s rotation to Vector3.ZERO after adding it to the hand. That will give it the same position and orientation of the hand.

1 Like