trizZzle The garbage is an Area2D.
I really liked your idea of using physics. I will definitely look into that because I probably will need it for later projects.
After reading on Finite state machine I ended up with a simply but working solution for my case and keep the project moving forward.
In the script attached to the garbage node this is what I added to keep track what should happened (I removed the actual code for moving the garbage but is mostly changing and checking the X and Y position + change state when reaching a point):
# VARS
enum States {ENTERING, M0VING, FALLING, DEAD}
var state = States.ENTERING
# IN THE PROCESS FUNCTION
if selected == false: # is the garbage picked up by the player, if not keep moving
if state == States.ENTERING:
# move garbage from A to B. If pos B reached change state
elif state == States.M0VING:
# move garbage from C to D. If pos D reached change state
elif state == States.FALLING:
# move garbage from E to F. If pos F reached change state
elif state == States.DEAD: :
# garbage has reached the end. Remove / play end animation
As an old Flash developer and a beginner in Godot I learned something new today; Enum and how to use is to get more readable code instead of using numbers to keep track of an objects state. Next up is learning properly Finite state machine concept and 2D physics. 🙂