I'm trying to make a collectible that when the player touches it, it follows it until it disappears at a certain point.
I know how to make it go away at a certain point, but I have a problem for it to follow the player, I tried to use directionto but when it is at its destination it starts shaking so I tried to use Joints, but I couldn't find a way to set nodea and nodeb through code, except setdeferred, but it didn't work either.
There is a way to make it follow the player?, I am using a KinematicBody2D for the player and the candy object.
The answer works perfectly, but away from this, I decided to share some information about how Celeste Collectibles works in terms of claiming, just in case somebody it's doing something inspired by this amazing game and has been hours searching about how Celeste works.
Generally, to claim a Strawberry, the player must be in-ground, not at a specific point. Also, each tile has a property to check if the floor is valid for claiming the collectible or not (This is made for some tiles like bridges or moving platforms, but also can be applied to normal tiles, so not all the ground you can touch it's a place for claiming strawberries.) Hope this helps people who are curious about Celeste functions and are willing to do something similar to it.