/// <summary> /// Updates position. Cascades down the train. /// </summary> public void OnFixedUpdate() { if (trackVehicle != null) { trackVehicle.Move(_velocity * Time.fixedDeltaTime); Vector3 front = trackVehicle.axleFront.GetWorldPosition().Vector3(); Vector3 rear = trackVehicle.axleRear.GetWorldPosition().Vector3(); transform.position = Vector3.Lerp(front, rear, 0.5f); transform.rotation = Quaternion.LookRotation(front - rear); //Update the next car in our train if (next != null) { next.OnFixedUpdate(); } } }