예제 #1
0
    // Update is called once per frame
    void Update()
    {
        Vector2 playerDirection = player.transform.position - transform.position;

        if (playerDirection.magnitude < aggroRange)
        {
            if (updateInput.Value)
            {
                velocity.x = Mathf.Sign(playerDirection.x) * moveSpeed;
                updateInput.UpdateValue(0.5f, false);
            }
            if (jumpTimer.Value)
            {
                velocity.y = jumpVelocity;
                jumpTimer.UpdateValue(jumpTime, false);
            }
        }
        else
        {
            if (controller.collisions.below)
            {
                velocity.x = 0;
            }
        }
        velocity.y += gravity * Time.deltaTime;
        controller.Move(velocity * Time.deltaTime);
    }
예제 #2
0
 private void Teleport(Portal portal)
 {
     StartCoroutine(ScreenFadeCoroutine(new Vector2(portal.location.x + 0.5f, portal.location.y + 0.5f)));
     portalCooldown.UpdateValue(2f, true);
 }