Hi guys, I’m having an issue at the moment where, for example, I have two platforms, I want one to move right 5 metres at a rate of 5 metres per second, and one to move down 1 metre at a rate of 1 metre per second. I want both platforms to pause for 0.5 seconds at their targets, to return to the original position at the same speed. This would equate to the objects being perfectly in synch with eachother. However, due to the imprecision of floating point maths, often these objects reach their initial or ending points at different times, due to moving something like 0.005 metres too short of their target when the other reaches it. Meaning over time the platforms become notably out of synch. Can anyone think of, or suggest a good way to ensure that this does not happen? I tried out a series of things, using lerps. Having each object contain a list of “partners” that each platform will wait for before starting again, but none of these implementations are perfect and are far from simple sublime solutions. Is there a better way to be doing this?
My solution to this was to have a parent object of all the platforms track whether they are at their half way of finished points, and keep a int for each object, if the objects need to stay in synch they all have to wait until the parent script states that all objects are at either half way or end.
The key point here is that I also needed to use an int with a value of 2 that would be reduced every frame, rather than having a bool that would be set to false as soon as a platform has moved away. That way I can ensure that when one object moves and is no longer at the end/mid point (and thus the “are all platforms at mid/end” value will now be false) it won’t prevent all platforms that execute after the first platform not moving, because it is still true for another frame.