예제 #1
0
    public void TeleportToAnchor()
    {
        int     index  = Random.Range(0, AnchorPoints.Count);
        Vector3 anchor = AnchorPoints[index];

        anchor = _teleportation.ConstraintPointToRectangle(anchor);
        _teleportation.TeleportToPoint(anchor);

        try
        {
            if (_sense.DetectedPlayer)
            {
                float playerX = _sense.PlayerLocation.position.x;
                _facingLeft = playerX < transform.position.x;
            }
        }
        catch
        {
            if (DebugMode)
            {
                Debug.LogWarning("The player no longer exists.  Hibernating this game object.");
            }

            gameObject.SetActive(false);
        }

        _animation = _facingLeft ? IdleLeft : IdleRight;
        AdvanceState();
    }
예제 #2
0
    private void TeleportBehindPlayer()
    {
        Vector3 target = _sense.PlayerLocation.position;

        target.x += _sense.PlayerState.isFacingRight
                                        ? -TeleportDistance
                                        : TeleportDistance;

        target = _teleportation.ConstraintPointToRectangle(target);
        _teleportation.TeleportToPoint(target);
        AdvanceToNextAiPhase();
    }