Somebody knows how to fix it?
idk if the problem is the raycast or the frame rate.
my code:
extends Node
@onready var ray_cast = $“../Head/Headcam/RayCast3D” @onready var marker_3D = $“../Head/Headcam/Marker3D”
func _physics_process(delta: float) → void:
var object = ray_cast.get_collider()
if ray_cast.is_colliding():
if object.is_in_group(“PICK”):
if Input.is_action_pressed(“primary”):
i just wanted to make an easy way to be able to pick up props, firstly it seems to work but when i shake the camera to much, the object falls down even though the input is pressed.
Usually in a situation like this, what you want to do is detect that an object has been picked up, and then attach it to the thing carrying it. Once you’ve attached, you don’t need to check for collision any more, and you don’t run the risk that some ordering problem in the physics calculations results in your raycast firing off to the side and not hitting the object.
I think what’s happening is that when you shake the camera, the raycast sometimes misses the thing you’re carrying, so it stops carrying it. Remember, the physics gets done in timesliced snapshots.