Controlling physics objects with raw forces often leads to jitter, overshoot, and “explosions.” PD Controllers (Proportional-Derivative) and their advanced cousin SPD (Stable Proportional Derivative) are the industry standard for making physics bodies follow targets—essential for VR hands, active ragdolls, and networked physics.
A PD controller is a feedback loop that calculates the necessary force to reach a target:
Force = (PositionError * kP) + (VelocityError * kD)
Traditional PD controllers can become unstable at high spring strengths or low framerates. SPD (Stable Proportional Derivative), introduced by Jie Tan, makes the controller implicit. It effectively calculates the force based on the predicted state of the next frame, making it nearly impossible to “explode.”
This is the core of high-end VR interaction (like Boneworks or Half-Life: Alyx).
Instead of teleporting a player’s position (which breaks physics and causes jitter), you can sync the Target Transform and use a PD controller locally to drive the actual Rigidbody.
public class PDController : MonoBehaviour {
public float kP = 1000f; // Spring
public float kD = 100f; // Damper
public Transform target;
private Rigidbody rb;
void FixedUpdate() {
Vector3 posError = target.position - transform.position;
Vector3 velError = (target.position - lastTargetPos) / Time.fixedDeltaTime - rb.linearVelocity;
Vector3 force = (posError * kP) + (velError * kD);
rb.AddForce(force);
lastTargetPos = target.position;
}
}