I’m attempting to simulate a situation where a child object’s movement in the z axis applies force to the parent rigidbody to give a realistic simulation of momentum - think of a rider on a bicycle that’s balanced and stationary throwing their weight backwards and forwards and causing the bike to roll back and forward under them in response.
rp = childObject.transform.localPosition; var rMov = rp.z - rpOld.z; var rSpeed = rMov / Time.fixedDeltaTime; var rAcc = (rSpeed- rSpeedOld) / Time.fixedDeltaTime; rb.AddRelativeForce(Vector3.forward * (-rAcc * 100)); rpOld = childObject.transform.localPosition; rSpeedOld = rSpeed;
This produces strange effects with jitter and off-axis or rotational forces applied to the rigidbody.
Using the speed of the child object (rSpeed) instead of it’s acceleration this doesn’t happen and the force is applied smoothly and in the correct direction - however momentum is not conserved properly like this.
Interpolation on/off on the rigidbody has no effect.