Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
 private void FixedUpdate()
 {
     if (followThis != null)
     {
         mover.TeleportPosition(followThis.transform.position + offset);
     }
 }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
 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);
         }
     }
 }