This is an innate problem of how computers simulate systems of motion.

Systems of motion can be thought of as the integration of an entity’s state. As an example, acceleration affects velocity which affects position.

Acceleration → Velocity → Position

## Simulation (no external forces)

In simulations where an entity is not affected by external forces (such as gravitational acceleration or collision impulses), the position of the entity is derived solely from the starting velocity (commonly referred to as `v0`

). This is the case because acceleration is not a factor, so velocity never changes i.e. the velocity will always be what it was when the object started moving.

Because of this, tick-rate (the update rate in one second) does not matter. The accumulation of positional changes (the integration of the system) always evaluates to the same number.

##
Mathematical example

Taking the following equation

p = p0 + v0 * dt

p: position

p0: starting position

v0: starting velocity

dt: delta time

…it can easily be shown that differing update rates do not matter when simulating a length of time.

**State values (dependent variables)**

p0 = (0, 0)

v0 = (1, 2)

**Delta time of 1.0 (one tick)**

dt = 1.0

p = p0 + v0 * dt

= **(1, 2)**

**Delta time of 0.25 (four ticks)**

dt = 0.25

p = p0 + (v0 * dt) * 4

= **(1, 2)**

In such a system, the entity either:

- Moves linearly in one direction forever
- Never moves

## Simulation with changing external forces

If we assume that the external forces of the simulation are constant, the simulation still does not dependent on tick-rate. A common example is gravity which, for all intents and purposes, remains constant. As such, the effect of gravity on the state of the entity can be calculated using calculus - no computers and tick-rates required.

The problem comes when wanting to calculate the state of the entity when external forces vary over time: collision forces, constraints and so on. The state of the system can no longer be reliably calculated via calculus because the forces in the system are, in simple terms, unknown over time.

This is why simulations run in ticks (a.k.a. steps); the state of the system is updated and the next state is computed based on this state. In theory, the result of these numerical simulations approach the true solution. However, you would need an impossibly high tick-rate for the simulation in order to produce such results - tick-rates so high that they can no longer run in real-time.

## Your problem

As seen in the illustration above, performing numerical simulation will inevitably make your entity stray from the target trajectory. To solve this problem, you have to take this fact into account.

## Solution

- Compute your new velocity based of off the vector between your
`click_point`

and your object position (like you’re already doing)
- Compute the next position,
`new_pos`

, and limit its distance from the `click_point`

- Compute the vector between this
*limited* `new_pos`

and your entity’s position. This will be your velocity.

If you have any questions, or the approach doesn’t work, please let me know.