/** * <summary>Snaps the object to a track at a given position along it</summary> * <param name="newTrack">The new DragTrack to snap to</param> * <param name="positionAlong">How far along the track, as a decimal of its length, to snap to</param> */ public void SnapToTrack(DragTrack newTrack, float positionAlong) { if (newTrack == null) { return; } if (track && newTrack != track) { track.OnDisconnect(this); } dragMode = DragMode.LockToTrack; if (IsAutoMoving()) { activeAutoMove.Stop(track, this, true); activeAutoMove = null; } track = newTrack; track.SetPositionAlong(positionAlong, this); if (_rigidbody) { _rigidbody.velocity = Vector3.zero; _rigidbody.angularVelocity = Vector3.zero; } }