private void FixedUpdate() { float dt = timeScale.DeltaTime(); if (velocity != Vector2.zero) { mover.TeleportPosition( UtilApproach.Vector2D(mover.GetPosition(), target, velocity * dt)); if (mover.GetPosition() == target) { // The object has reached its destination. // Do different things depending on the current state. if (state == State.Rise) { state = State.Idle; timerIdle.Run(); } else if (state == State.Lower) { Destroy(gameObject); } } } timerWarning.Tick(dt); timerIdle.Tick(dt); }
private void FixedUpdate() { if (followThis != null) { mover.TeleportPosition(followThis.transform.position + offset); } }
private void RestrictPosition() { Vector3 newPos = transform.position; switch (axis) { case LimitAxis.X: newPos.x = value; break; case LimitAxis.Y: newPos.y = value; break; } mover.TeleportPosition(newPos); }
private void FixedUpdate() { if (lerping) { Vector2 stepVelocity = velocity * timeScale.DeltaTime(); if (stepVelocity.sqrMagnitude > (destination - mover.GetPosition()).sqrMagnitude) { mover.TeleportPosition(destination); OnCompleted(); } else { mover.OffsetPosition(stepVelocity); } } }