Compute 1D motion profile with acceleration, deceleration and mid-course target change
14:53 16 Nov 2025

I need an analytic solution for a 1D motion controller. Initial state: x=0, v=0. Parameters: a_acc = 50, a_dec = 30, v_max = 40. Given a target position (e.g. x=20) the object should:

  • accelerate up to v_max (if possible),
  • cruise if needed,
  • then decelerate so it arrives exactly at the target with v = 0.

Targets can change mid-flight (for example, switch to x = -10). I implemented a per-frame integrator (delta ≈ 33 ms) that updates velocity and position each frame, but it accumulates significant error and produces incorrect velocity profiles.

What I want: a concise algorithm or formula to compute the correct velocity/position profile so the object always reaches the current target at v=0. Also how to handle an instantaneous target change (recompute profile from current x,v).

What I tried

  • Discrete per-frame integration (update v by ±a * dt, clamp to v_max, update x += v*dt). Results drift/overshoot and the deceleration begins at wrong times.

Desired answer scope

  • How to compute the distances/times for accelerate → cruise → decelerate analytically.
  • How to decide whether the profile is accelerate→decelerate (no cruise) or accelerate→cruise→decelerate.
  • How to handle recomputing the profile when the target changes, given current x and v.

Minimal equations or pseudo-code in the answer are fine.

game-development physics-simulation kinematics motion-planning math

game-development game-physics physics unreal-engine5