I might be missing some simple thing but I'm not I am able to wrap my head around this. Normally, if I want to move two objects to different positions so they arrive at the same time I would use a lerp like so:
var speed = 2.0f; var amount = Math.Min(1f, this.elapsedTime * speed); var obj1NewPosition = Vector2.Lerp(this.obj1Start, this.obj1End, amount); var obj2NewPosition = Vector2.Lerp(this.obj2Start, this.obj2End, amount); this.obj1Position = obj1NewPosition; this.obj2Position = obj2NewPosition; this.elapsedTime += dt;
But I want to do this in a way where I only add to their positions:
var speed = 2.0f; this.obj1Position += obj1Vector * speed * dt; this.obj2Position += obj2Vector * speed * dt; // obj1Vector is a normalized vector headed to obj1End // obj2Vector is a normalized vector headed to obj2End
How do I make the second approach work such that each object will arrive at the destination I choose at the same time by only adding to their positions?
I don't have to consider acceleration or deceleration, simply: have two objects arrive at their respective destinations at the same time and then stop.