I’m trying to move an object to the position of an other object and I can’t stop the moving object.
When the moving object get to the position of the other object, it start shaking because I think it keep trying to move even though it already in the position. I have tried to check the position of the moving object and move it only when it position is different. I have also tried to stop the object when it position is equal. Nothing works .
I have no idea why.
I have shared the project on GDevApp
gdevapp.com/play.html?g=54fcab6 … 68507ce278
You can also find it as “test2” in public games to make a copy and check it.
Anybody could help me out what is wrong with it or confirm it if it a bug?
You should test a position interval (from 99.9 to 100.1 for example) because the position will never be exactly equal to 100.
But why it never be the same
I just checked using text objects and the moving object stops by 20±15 pixels before the position of the target, that’s why it shaking, because it never get there actually but keep trying to move there. Why is that?
Could you or 4ian fix it please, can I request this fix?
EDIT:// just solved the problem by decreasing/increasing it X,Y position until fit.
The objects are moved in function of the time (TimeDelta()), a float, so the positions are floats too (e.g. 99.9), to avoid this, you could round the position at the end of the movement ( Object X position = round(Object.X()) ), but you’ll lose the linear time dependency by a little random value, maybe resulting in weird movements
You could check the distance too, if the objects are closely enough, just copy positions to fit