/// <summary> /// Starts the defined movement if it has not already been started. /// </summary> public void StartMovement() { if (currentTime > 0) { return; } //construct the real pivot. movedObject.transform.position = initial; Vector3 middle = QVectorCalculations.GetVector3Middle(initial, final); Vector3 nearest = QVectorCalculations.GetNearestPointOnLine(middle, (final - initial), pivot); Vector3 dir = (pivot - nearest).normalized; Vector3 realPivot = middle; //construct circle. v1 = (initial - realPivot).normalized * (initial - realPivot).magnitude; v2 = dir * (initial - realPivot).magnitude; pivot = realPivot; currentTime = movementTime; //do the movement if (isRigidBodyMovement) { //rigidbody movement QGradualMovementManager.AddGradualMovement(rigidbody, this, movementStacked, attemptMerge); } else { //regular movement. QGradualMovementManager.AddGradualMovement(movedObject, this, movementStacked, attemptMerge); } }
private void OnDestroy() { if (singleton == this) { DisableMovementEnumeration(); gradualMovements = new Dictionary <GameObject, Queue <QIGradualMovement> >(); rigidGradualMovements = new Dictionary <Rigidbody, Queue <QIGradualMovement> >(); currentGradualMovements = new Dictionary <GameObject, AggregateGradualMovement>(); currentRigidGradualMovements = new Dictionary <Rigidbody, AggregateGradualMovement>(); singleton = null; } }
private void Awake() { if (singleton != null) { Destroy(gameObject); return; } singleton = this; currentProperties = defaultProperties; if (currentProperties.dontDestroyOnLoad) { DontDestroyOnLoad(gameObject); } SceneManager.activeSceneChanged += OnSceneChanged; EnableMovementEnumeration(); }