![]() |
| ||
| Vector2 Maths Problem (Acceleration/Deceleration towards a Point) Hi, I am writing a game in which an object at a PointF travelling at a current velocity (Vector2) is trying to reach a destination PointF (which can change between movement steps) At each step of movement I need to decide the acceleration vector that will get to the point the fastest. So the result should be the ship adjusts its current velocity so that it always moves towards the target point at stead acceleration unless doing so would mean there isn't enough time to slow down before reaching it in which case it should begin decelerating. This has been doing my head in a bit and the code I have at the moment seems to just make the ships orbit the point: Vector2 v_target = new Vector2(target.X,target.Y); |
| ||
| Re: Vector2 Maths Problem (Acceleration/Deceleration towards a Point) Well I've eventually worked out the following (after talking to a friend of mine), It does a good job at flying from any fixed point to the target using appropriate accelleration/deceleration and is able to compensate fairlly when the you wave the target point around and they can usually get back to the point with only a couple of tight concentric orbits. Feel free to use the code in your own programs if you ever need to:
|
| All times are GMT -4. The time now is 10:23 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC