/** * <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; } }
/** * <summary>Stops the object from moving without the player's direct input (i.e. through Actions).</summary> * <param name = "snapToTarget">If True, then the object will snap instantly to the intended target position</param> */ public void StopAutoMove(bool snapToTarget = true) { if (IsAutoMoving()) { activeAutoMove.Stop(track, this, snapToTarget); activeAutoMove = null; _rigidbody.velocity = Vector3.zero; _rigidbody.angularVelocity = Vector3.zero; } }