/// <summary> /// Moves the given body along the defined path. /// </summary> /// <param name="path">The path.</param> /// <param name="body">The body.</param> /// <param name="time">The time.</param> /// <param name="strength">The strength.</param> /// <param name="timeStep">The time step.</param> public static void moveBodyOnPath(Path path, Body body, float time, float strength, float timeStep) { var destination = path.getPosition(time); var positionDelta = body.position - destination; var velocity = (positionDelta / timeStep) * strength; body.linearVelocity = -velocity; }
/// <summary> /// Moves the given body along the defined path. /// </summary> /// <param name="path">The path.</param> /// <param name="body">The body.</param> /// <param name="time">The time.</param> /// <param name="strength">The strength.</param> /// <param name="timeStep">The time step.</param> public static void moveBodyOnPath( Path path, Body body, float time, float strength, float timeStep ) { var destination = path.getPosition( time ); var positionDelta = body.position - destination; var velocity = ( positionDelta / timeStep ) * strength; body.linearVelocity = -velocity; }