Godot Version
4.6.2
Question
So I started following this card game tutorial for Godot https://www.youtube.com/watch?v=1mM73u1tvpU&list=PLNWIwxsLZ-LMYzxHlVb7v5Xo5KaUV7Tq1&index=2
In the tutorial he uses this code in _process() to get the clicked on card to follow the mouse position
I noticed that with this code, it causes the card to immediately snap to position so that the center of the card aligns with the mouse position.
I thought it would be cool to try and edit the code so that the card moves relative to where it was clicked. I figured I could to do this by getting the distance between the center of the card and the mouse position and adjusting the cards position accordingly. This is how I edited the code to achieve this.
Now, it almost sort of worked. Except, when you click on a card, now, it starts flipping across the mouse position super fast.

I added a line print(distance_x) to see what it was returning, and turns out, the value does in fact flip between the positive and the negative on each tick.
Things is, I can’t see a reason in my code that this would be happening. Thought maybe it was a weird interaction with the clamp function, but I tried removing it and it still did the same thing. Wondering if anyone hear has some idea why this is happening.



