0 votes

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

asked Jul 3 in Projects by Ogeeice (126 points)

1 Answer

0 votes

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
answered Jul 4 by Dlean Jeans (3,545 points)
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 How to use this Q&A? before posting your first questions.