-
Trouble moving an object
Hi, I'm new here so I hope this hasn't been posted before. I tried searching, but didn't find much that was useful.
I have two objects. One is supposed to move to the location of the other. Let's say Object A is the one I want to move and Object B is the destination. I set it up so that if the x coordinate of Object B is greater than the x coordinate of Object A, then A changes it's x coordinate position by +1. If x of B is less than x of A, then A's x coordinate changes by -1. Same with the y coordinate. This works fine, but I wanted to have different speeds so instead of changing the position by 1, I tried 0.5.
The problem is that with 0.5 plugged in, Object A will only move negative along the axis; it'll go up or to the left, but not down or to the right. I don't know if this is a bug or something where the math is canceling out or what, but I'd appreciate any help or ideas. If you need any extra info, let me know and I'll post it. Thanks.
-
Are you using build 255 of MMF2? Or are you using the demo version?
-
It's the usual problem of object positions not storing floats. You just need to store the X and Y coordinates in alterable values (which do support floats), and then always set the object position to those.
If you do a search, you should find plenty of related questions, as this is something that comes up a lot.
-
Everything appears to be up to date.
Thanks, MuddyMole, I'll give that a try.