void FixedUpdate() { if (Spline) { var v = Input.GetAxis("Vertical") * VSpeed; var h = Input.GetAxis("Horizontal") * HSpeed; Vector3 p; // get nearest TF and point on spline mTF = Spline.GetNearestPointTF(transform.localPosition, out p); // apply forward thrust along spline direction (tangent) if (v != 0) { mRigidBody.AddForce(Spline.GetTangentFast(mTF) * v, ForceMode.Force); } // apply side thrust to left/right from the spline's "forward" vector if (h != 0) { Vector3 offset = Spline.GetExtrusionPointFast(mTF, 1, 90); Vector3 hdir = p - offset; mRigidBody.AddForce(hdir * h, ForceMode.Force); } if (Input.GetKeyDown(KeyCode.Space)) { mRigidBody.AddForce(Vector3.up * JumpForce, ForceMode.Impulse); } // continously drag toward the spline to add some magic gravity mRigidBody.AddForce((Spline.Interpolate(mTF) - transform.localPosition) * CenterDrag, ForceMode.VelocityChange); } }