I'm trying to move two objects away from each other at a proportional distance, but on different scales. I'm not quite sure how to do this. Object A can go from position 0.1 to 1. Object B has no limits. If object B is decreasing, then Object A should be decreasing at rate R. Likewise, if Object B is increasing, then Object A increases at rate R. How can I tie these two Object positions together so that in an update loop, they automatically update their positions?
I tried using:
ObjA.Pos.X += 0.001f * ObjB.VelocityY; //0.001f is the rate
This works but there's an error each time it runs. ObjA starts off at its max position
1 but then the next time it will stop at 0.97, 0.94, 0.91 etc.. This is due to the
0.001f rate I put in. Is there a way to control the rate, yet not end up with the rounding error?
EDIT - To clarify the scenario: The user can provide a force to Object B in a vertical motion (2D game). Gravity will bring the object back down once the user lets go of the up/down button. As the object moves up or down, I want object A to move left and right on the X axis. Maximum distance to the right can be '1', and to the left can be '0.1'. Therefore, if the user keeps holding up forever,object A will still only be at 0.1.
Object A at max 1 = Object B at position 4.5 (this is the starting position)
Object A at min 0.1 = object B at position +/- 9.9
Obejct B does take the game time into account.