Player pick up object

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ogeeice

I have a player of type kinematicbody 3D and I want him to be able to pick up a lamp of type starticbody3d with an area node attached how do I make my player pick it up and parent the lamp to him so it goes wherever the player goes

:bust_in_silhouette: Reply From: Dlean Jeans

Connect the StaticBody signal input_event (or of the Area if you want a different shape otherwise you don’t need a Area) to a script:

func _on_StaticBody_input_event(camera, event, click_position, click_normal, shape_idx):
	if event is InputEventMouseButton and event.pressed:
		var static_body = $StaticBody
		static_body.get_parent().remove_child(static_body)
		$Player.add_child(static_body)
		# optionally adjust the position