Grab & Move objects with a player

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

Hello, sorry if this seems like basic problem, but i’m by no means a programmer and am struggling with this. ANY HELP is extremely appreciated.

What am trying do is get the bird (player) to pick up the trash (object) with a button and be able to move around with it; holding the trash in his beak. I also want him to be able to release it into a trashcan eventually. However I’m not exactly sure on how to do that.

Current Project Progress

:bust_in_silhouette: Reply From: Mrpaolosarino

There are many ways you can do this like Statemachine. But in the beginner,
the basic logic is:
if you press a button and if your player’s area and the trash’s area overlapped, then you’ll create a boolean :

var picked = false
if picked == true:
     Trash.global_position = Player.global_position.

And then if you want to release, there are many ways you can do it, but here is some example:

if Input.is_action_just_pressed("ui_accept"):
       picked = false