예제 #1
0
    void FindTarget()
    {
        if (forceTarget != null)
        {
            return;                      // 우선 타겟이 있을 경우 적을 탐색하지 않음
        }
        Transform closest = GetClosest();

        currentTarget = closest;
        if (currentTarget == null)
        {
            return;
        }

        if (attackRangeCollider.OverlapPoint(currentTarget.position)) // 현재 타겟이 사거리 내에 있다면 타겟 변경 없음
        {
            state = ActorState.idle;
            return;
        }

        if (!attackRangeCollider.OverlapPoint(closest.position)) // 가장 가까운 타겟이 사거리 내에 없다면 추적 상태로 변경
        {
            state = ActorState.chase;
        }
    }
예제 #2
0
    private void ProcessTouchInput()
    {
        if (Input.touchCount > 0 && !ballAnimator.GetBool("Launched"))
        {
            touch = Input.GetTouch(0);

            if (touch.phase == TouchPhase.Began && ballCollider2D.OverlapPoint(Camera.main.ScreenToWorldPoint(touch.position)))
            {
                initialTouchPos = touch.position;
                newTouchPos     = initialTouchPos;
            }

            else if (touch.phase == TouchPhase.Ended && ballCollider2D.OverlapPoint(Camera.main.ScreenToWorldPoint(initialTouchPos)))
            {
                newTouchPos = touch.position;
                float fingerSpeed = touch.deltaPosition.magnitude / touch.deltaTime;
                if (fingerSpeed > minFingerSpeed && (Camera.main.ScreenToWorldPoint(newTouchPos).y - Camera.main.ScreenToWorldPoint(initialTouchPos).y) > minYMoveDistance)
                {
                    float xDifference     = Camera.main.ScreenToWorldPoint(newTouchPos).x - Camera.main.ScreenToWorldPoint(initialTouchPos).x;
                    float horizontalForce = xDifference;

                    LaunchBall(horizontalForce * horizontalForceMultiplier);
                }
            }
        }
    }
예제 #3
0
 void MouseEvent()
 {
     if (!invincible && inRange && Input.GetMouseButtonDown(0))
     {
         //Debug.Log(self.InRange);
         if (hitArea.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
         {
             if (!GameSystem.stop)
             {
                 StartCoroutine("DamageEffects");
                 Damage(miko.KamiAttack);
                 rb.velocity = Vector2.zero;
                 Debug.Log(hp);
                 if (hp <= 0)
                 {
                     rb.gravityScale   = 1.0f;
                     stun              = true;
                     _animator.enabled = false;
                     sr.sprite         = stunS;
                     ActiveStunEffect(true);
                     StartCoroutine("Revivals");
                 }
             }
         }
     }
 }
예제 #4
0
    // Warp a ray through a black hole
    protected void BlackHoleWarp()
    {
        // Get direction from center of first black hole to the hit point
        Vector2 directionFromCenter = (hit.point - (Vector2)hit.transform.position).normalized;

        // Add black hole center and blank value to path
        path.Add((Vector2)hit.transform.position);
        path.Add(new Vector2(float.NaN, float.NaN));

        // Get the point on the edge of the 2nd black hole in the same direction
        GameObject       exitBlackHole = hit.transform.GetComponent <BlackHole>().BlackHoleExit;
        CircleCollider2D collider      = exitBlackHole.GetComponent <CircleCollider2D>();
        Vector2          edgePoint     = (Vector2)exitBlackHole.transform.position + directionFromCenter;

        // Add second black hole center to path
        path.Add(exitBlackHole.transform.position);

        // Move into black hole
        ray.origin = edgePoint;
        int tries = 0;

        while (!collider.OverlapPoint(ray.origin) && tries < 1000)
        {
            ray.origin -= (Vector3)(directionFromCenter * 0.01f);
            tries++;
        }

        // Move out of black hole
        while (collider.OverlapPoint(ray.origin))
        {
            ray.origin += ray.direction * 0.01f;
        }

        // Activate black hole
        BlackHole bhScript = exitBlackHole.GetComponent <BlackHole>();

        bhScript.Pointers[color].Active = true;
        bhScript.FrameBuffers[color]    = 1;

        // Set exit pointer
        Pointer exitPointer = bhScript.Pointers[color];

        exitPointer.SetStartPoint(ray.origin);
        exitPointer.SetStartDirection(ray.direction);
        exitPointer.Active = true;
    }
예제 #5
0
 private void InputController_OnTap(Vector2 tapPosition)
 {
     if (circleCollider.OverlapPoint(tapPosition))
     {
         OnTap();
         isDestroyed = true;
         Destroy(gameObject);
     }
 }
예제 #6
0
 // Update is called once per frame
 void Update()
 {
     mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
     if (Input.GetMouseButtonDown(0) && (wire == null) && ToolController.SelectedTool == ToolController.ToolType.WIRE)
     {
         if (col.OverlapPoint(mousePosition))
         {
             ConnectWire();
         }
     }
     else if (Input.GetMouseButtonDown(0) && (wire != null) && (connectingWire == null) && ToolController.SelectedTool == ToolController.ToolType.WIRE)
     {
         if (col.OverlapPoint(mousePosition))
         {
             MoveWire();
         }
     }
 }
예제 #7
0
    // Update is called once per frame
    void Update()
    {
        if (isTree && fieldState == FIELD_STATE.EMPTY)
        {
            Seed.SetActive(true);
            fieldState = FIELD_STATE.SEEDED;
            StartCoroutine(WaitUntilPlant(Random.Range(MinTimeToPlant, MaxTimeToPlant)));
        }


        if (Input.GetMouseButtonDown(0))
        {
            Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            if (colliderField.OverlapPoint(mousePosition))
            {
                switch (fieldState)
                {
                case FIELD_STATE.EMPTY:
                {
                    GetComponent <AudioSource>().PlayOneShot(AudioSeed);
                    Seed.SetActive(true);
                    fieldState = FIELD_STATE.SEEDED;
                    StartCoroutine(WaitUntilPlant(Random.Range(MinTimeToPlant, MaxTimeToPlant)));
                    Debug.Log("lol");
                }
                break;

                case FIELD_STATE.RIPE:
                {
                    Plant_Grown.SetActive(false);
                    fieldState = FIELD_STATE.EMPTY;
//						Destroy(ParticleEffect);
                    GetComponent <AudioSource>().PlayOneShot(AudioHarvest);

                    GameObject EffectCollect = Instantiate(ParticleCollect) as GameObject;
                    EffectCollect.transform.parent        = ParticlesGO.transform;
                    EffectCollect.transform.rotation      = new Quaternion(0, 0, 0, 0);
                    EffectCollect.transform.localPosition = Vector3.zero;

                    IconHarvest.SetActive(true);
                    Animation anim = (Animation)IconHarvest.GetComponent("Animation");
                    anim.Play();

                    StartCoroutine(DisableIcon(1.0f));
                }
                break;

                default:
                    break;
                }
            }
        }
    }
예제 #8
0
 public bool IsTouch(Vector2 pos)
 {
     if (colider.OverlapPoint(pos))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #9
0
    public override bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera)

    {
        bool isRay = base.IsRaycastLocationValid(screenPoint, eventCamera);

        if (isRay && (collider2d != null))
        {
            bool isTrig = collider2d.OverlapPoint(screenPoint);
            return(isTrig);
        }
        return(isRay);
    }
예제 #10
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector3 wp = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            if (coll.OverlapPoint(wp))
            {
                CashOut();
            }
        }
    }
예제 #11
0
    void IDragHandler.OnDrag(PointerEventData eventData)
    {
        Vector2 delta = eventData.position - pointerStartPosition;

        transform.position = startingPosition + delta;

        if (!circle.OverlapPoint(transform.position))
        {
            transform.position = circle.ClosestPoint(transform.position);
        }

        axis = delta / circle.radius;
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            var hitCollider   = _collider.OverlapPoint(mousePosition);

            if (hitCollider)
            {
                OnClicked(EventArgs.Empty);
            }
        }
    }
예제 #13
0
 public virtual void TryInteract(GameObject user)
 {
     interactor = user;
     //if (Vector2.Distance(interactionWorldPoint, user.transform.position) <= maxDistance)
     if (circleCollider.OverlapPoint(interactor.transform.position) == true)
     {
         Interact();
     }
     else
     {
         Debug.Log(user.name + " is too far to interact with " + interactionWorldPoint);
     }
 }
예제 #14
0
    public bool CheckIfPointInCollider(Vector2 location)
    {
        Node targetNode = grid.NodeFromWorldPoint(new Vector3(location.x, location.y, 0));

        if (targetNode.walkable && !rangeToIgnore.OverlapPoint(location))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
예제 #15
0
    void Update()
    {
        vec.y = vec.y - speed * Time.deltaTime;
        transform.position = vec;

        if (Input.GetMouseButtonDown(0))
        {
            if (bc.OverlapPoint(c.ScreenToWorldPoint(Input.mousePosition)))
            {
                obj.enabled   = true;
                transform.tag = "withpoty";
                anim.Play("clicked");
            }
        }
    }
예제 #16
0
 void Update()
 {
     if (isGameStarted && Input.GetMouseButtonDown(0))
     {
         var mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         if (targetCollider.OverlapPoint(mousePosition))
         {
             clickCount++;
             if (clickCount == clickGoal)
             {
                 Macro.Win();
                 Macro.EndGame();
             }
         }
     }
 }
예제 #17
0
 void Update()
 {
     if (canOpen && !empty)
     {
         if (cc.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
         {
             if (Input.GetMouseButtonDown(0))
             {
                 empty     = true;
                 sr.sprite = s;
                 EventTextManager.Instance.Set("霊力を" + amount.ToString() + "Pを手に入れた");
                 Mikochan.Instance.GetExp(amount);
             }
         }
     }
 }
예제 #18
0
    private int GetLittleEmojisAmount()
    {
        GameObject[] playersInGame    = GameObject.FindGameObjectsWithTag("Player");
        int          playersInTheZone = 0;

        foreach (GameObject player in playersInGame)
        {
            if (collider.OverlapPoint(player.transform.position))
            {
                playersInTheZone++;
            }
        }

        Debug.Log("There are " + playersInTheZone + " players in the zone.");

        return(playersInTheZone - 1);           // -> removing the big player from the process
    }
예제 #19
0
    void CheckWaypointProximity()
    {
        if (path == null || path.Length == 0)
        {
            return;
        }

        if (circleCollider.OverlapPoint(currentWaypoint))
        {
            targetIndex++;
            if (targetIndex >= path.Length)
            {
                StopMoving();
                return;
            }
            currentWaypoint = path [targetIndex];
        }
    }
예제 #20
0
    //This should probably be somewhere else, but I'm running out of time here!
    public void SetupStars()
    {
        int numStars = Random.Range(minStars, maxStars);

        if (numStars < 0)
        {
            numStars = 0;
        }
        for (int i = 0; i < numStars; i++)
        {
            Vector3 rndPos = Vector3.zero;
            while (radius.OverlapPoint(rndPos))
            {
                rndPos   = Camera.main.ScreenToWorldPoint(new Vector3(Random.Range(0, Screen.width), Random.Range(0, Screen.height), 0f));
                rndPos.z = 0f;
            }

            Instantiate(starPrefab, rndPos, Quaternion.identity);
        }
    }
예제 #21
0
 private void TouchInput()
 {
     RegisterTouchInfos();
     if (_firstTouch.phase == TouchPhase.Began && _col.OverlapPoint(_firstTouchPos))
     {
         TouchOnPlayer();
     }
     if (_touchOnPlayer && _touchDist >= _activationDist)
     {
         EnableWind();
     }
     if (WindPushArea.activeSelf)
     {
         RotateToTouch();
         if (AutoFire)
         {
             Fire();
         }
         else
         {
             if (Input.touchCount >= 2)
             {
                 Fire();
             }
             else
             {
                 CancelInvoke("ThrowGrain");
                 _isFiring = false;
             }
         }
     }
     if (_firstTouch.phase == TouchPhase.Ended)
     {
         _isFiring      = false;
         _touchOnPlayer = false;
         CancelInvoke("ThrowGrain");
         DisableTouchArea();
     }
 }
예제 #22
0
    // Vérifie s'il faut activer le trigger une première fois,
    // ainsi que le dézoom ensuite si on est dans la zone d'effet
    private void CheckTriggerActivation()
    {
        // Activation la 1ère fois si on est pile sur le point
        if (!isEnabled && boxColliderComponent.OverlapPoint(cursorObject.transform.position))
        {
            print("Trigger activated !");
            isEnabled = true;

            boxColliderComponent.enabled    = false;
            circleColliderComponent.enabled = true;
            //imageComponent.color = disabledColor;

            // Destruction du trigger visuel avant activation
            Transform childCamera = transform.GetChild(0);
            if (childCamera != null)
            {
                Destroy(childCamera.gameObject);
            }
        }

        if (isEnabled)
        {
            // Dezoom lorsqu'on est dans le cercle d'effet (on = le centre de l'écran)
            if (circleColliderComponent.OverlapPoint(Vector2.zero))
            {
                if (!isActive)
                {
                    print("Trigger in dezoom");
                    //imageComponent.color = enabledColor;
                    isActive = true;
                }
            }
            else
            {
                //imageComponent.color = disabledColor;
                isActive = false;
            }
        }
    }
예제 #23
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButton(0) && !m_IsConnected)
        {
            Vector3   mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            MouseLine line     = ServiceProvider.instance.mouseLine;
            mousePos.z = 0;
            if (m_Collider.OverlapPoint(mousePos))
            {
                CameraMovement.m_CanMove = false;
                if (line.selected == false)
                {
                    line.positionA = this.position;
                    line.selected  = true;
                }
                line.AddPoint(this);
            }
            if (line.positionA != Vector3.zero)
            {
                line.positionB = mousePos;
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            CameraMovement.m_CanMove = true;
            MouseLine line = ServiceProvider.instance.mouseLine;
            line.positionB = Vector3.zero;
            line.Reset();
        }

        if (m_IsConnected)
        {
            m_Renderer.enabled = false;
        }
        else
        {
            m_Renderer.enabled = true;
        }
    }
예제 #24
0
 // Update is called once per frame
 void Update()
 {
     if (!invincible)
     {
         if (inRange && Input.GetMouseButtonDown(0))
         {
             //Debug.Log(self.InRange);
             if (cc.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
             {
                 MouseEvent();
             }
         }
     }
     if (!stun)
     {
         DecideDir();
     }
     else if (hp <= 0)
     {
         FlyAway();
     }
     //Debug.Log(gashaHead.position);
 }
예제 #25
0
    private void tocandoPantalla()
    {
        int numPresiones = 0;

        foreach (Touch toque in Input.touches)
        {
            if (toque.phase != TouchPhase.Ended && toque.phase != TouchPhase.Canceled)
            {
                numPresiones++;
            }
        }
        if (numPresiones > 0 | Input.GetMouseButtonDown(0))
        {
            //Vector3 posicionTap = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
            Vector3 posicionTap   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2 posicionTap2D = new Vector2(posicionTap.x, posicionTap.y);
            bool    presiono      = presionar.OverlapPoint(posicionTap2D);
            if (presiono)
            {
                personaje = this.transform.parent.gameObject.GetComponent <Personaje> ();
                personaje.MoverJugadorDerecha();
            }
        }
    }
예제 #26
0
 public bool OverlapPoint(Vector2 pos)
 {
     return(circleCollider.OverlapPoint(pos));
 }
    void Update()
    {
        ////Are we touching the screen and not already moving?
        if (Input.GetButtonDown("Fire1") && !moving)
        {
            ////Get touch position.
            Vector2 touchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            ////Are we touching the horse, then move?
            ////Otherwise we are aiming the bow.
            if (movingCollider.OverlapPoint(touchPosition))
            {
                moving = true;
            }
            else
            {
                aiming = true;
            }
        }

        ////If we are moving?
        if (moving)
        {
            ////Move toware the touch position.
            Vector2 touchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            ////Make sure we are not flying :(
            float horseY = transform.position.y;
            if (horseY > 0)
            {
                touchPosition = new Vector2(transform.position.x, 0);
            }

            transform.position = Vector2.MoveTowards(transform.position, touchPosition, speed * Time.deltaTime);
        }

        ////If we are aiming?
        if (aiming)
        {
            Vector2 touchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            var     y             = ArrowController.ArrowPoint.position.y - touchPosition.y;
            var     x             = ArrowController.ArrowPoint.position.x - touchPosition.x;
            angle             = (Mathf.Atan2(-y, -x) * Mathf.Rad2Deg);
            BowArm.rotation   = Quaternion.Euler(new Vector3(0, 0, angle));
            FireHalo.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
        }

        ////Alway shoot the bow
        if (firing)
        {
            if (Time.time > arrowNext)
            {
                arrowNext = ArrowController.FireArrow(angle);
                bowSound.Play();
            }
        }


        ////Reset controls then the finger is up.
        if (Input.GetButtonUp("Fire1"))
        {
            moving = false;
            aiming = false;
        }
    }
예제 #28
0
 public bool DoesCollide(Vector2 pos)
 {
     return(Collider.OverlapPoint(pos));
 }
예제 #29
0
    override public int InputUpdate()
    {
        if (Input.touchCount > 0)
        {
            for (int i = 0; i < Input.touchCount; i++)
            {
                Touch t = Input.GetTouch(i);

                //stickpos z = 0;
                Vector3 stickPosZ0 = gameObject.transform.position;
                stickPosZ0.z = 0;

                //touch pos.
                Vector3 touchWorldPos = tartegCamera.ScreenToWorldPoint(new Vector3(t.position.x, t.position.y, 0));
                touchWorldPos.z = 0;

                //touch delta pos.
                Vector3 touchdeltaWorldPos = tartegCamera.ScreenToWorldPoint(new Vector3(t.deltaPosition.x, t.deltaPosition.y, 0));
                touchdeltaWorldPos.z = 0;

                //可出現stick的範圍.
                if (isUseStickAppearArea && AppearArea != null)
                {
                    if (AppearArea.OverlapPoint(touchWorldPos) && (t.phase == TouchPhase.Began))
                    {
                        transform.position = new Vector3(touchWorldPos.x, touchWorldPos.y, transform.position.z);
                    }
                }


                //是否點中.
                if (circleC2d.OverlapPoint(touchWorldPos))
                {
                    //是否別人用了.
                    GameVirtualInputBase touchedInput = GameVirtualInput.instance.isTouched(i);
                    //別的 input 用了.
                    if (touchedInput != null)
                    {
                        continue;
                    }
                }
                else
                {
                    continue;
                }

                //暫時記下 touch id;
                touchID = i;

                //Debug.Log("in " + i.ToString() + " " + t.phase.ToString());
                //開始.
                if (t.phase == TouchPhase.Began)
                {
                    circleC2d.radius = oldCircleR * colliderTouchScale;
                    holdTime         = 0;
                    if (onDownEvent != null)
                    {
                        onDownEvent(Vector2.zero);
                    }
                }

                //按住.
                if (t.phase == TouchPhase.Stationary)
                {
                    holdTime += Time.deltaTime;
                }

                //移動.
                if (t.phase == TouchPhase.Moved)
                {
                    //direction.
                    Vector3 directionWorld = touchWorldPos - stickPosZ0;
                    //算出移動多少比率, 半徑.
                    Vector2 directionV2               = new Vector2(directionWorld.x, directionWorld.y);
                    float   directionWorldLeng        = directionV2.magnitude;
                    float   cirRadius                 = oldCircleR * transform.localScale.x;
                    float   directionWorldRadiusRatio = directionWorldLeng / cirRadius;



                    if (moveStick)
                    {
                        //stick 跟著移動.
                        if (directionWorldLeng >= cirRadius * minStickTomovek)
                        {
                            //Debug.Log(sdirvec.magnitude);
                            transform.position += directionWorld * 0.1f;
                        }
                    }


                    //香菇頭.
                    stickHead.transform.position = transform.position + directionWorld.normalized * Math.Min(directionWorldRadiusRatio, 1) * cirRadius;


                    //collider 跟著移動.
                    circleC2d.gameObject.transform.position = new Vector3(touchWorldPos.x, touchWorldPos.y, circleC2d.gameObject.transform.position.z);



                    //debugtext.text = directionWorldRadiusRatio.ToString();

                    if (directionWorldRadiusRatio > minToMove)
                    {
                        if (onMoveEvent != null)
                        {
                            onMoveEvent(directionV2.normalized);
                        }
                    }
                }


                //放開.
                if (t.phase == TouchPhase.Ended || (t.phase == TouchPhase.Canceled))
                {
                    //collider 移回去原位.
                    SetUnTouched();
                    if (onUpEvent != null)
                    {
                        onUpEvent(Vector2.zero);
                    }

                    //長放或短放.
                    if (holdTime >= minLongUpTime)
                    {
                        if (onLongUpEvent != null)
                        {
                            onLongUpEvent(Vector2.zero);
                        }
                    }
                    else
                    {
                        if (onShortUpEvent != null)
                        {
                            onShortUpEvent(Vector2.zero);
                        }
                    }
                }


                //按住事件.
                if (onHoldEvent != null && holdTime > 0)
                {
                    onHoldEvent(new Vector2(holdTime, holdTime));
                }



                //debugtext.text = touchID.ToString();

                break;
            }
        }

        return(touchID);
    }
예제 #30
0
    void Update()
    {
        if (animator.GetCurrentAnimatorStateInfo(0).IsTag("Climb") || win)
        {
            return;
        }

        animator.SetBool("Grounded", isGrounded);

        hori = Input.GetAxis("Horizontal");

        //Only update jump to true
        if ((Input.GetButtonDown("Jump") && isGrounded) || (Input.GetButton("Jump") && isOnWall))
        {
            jump = true;
            animator.SetTrigger("Jump");
        }

        //Ledging
        if (Input.GetButton("Ledge"))
        {
            List <Collider2D> cols = new List <Collider2D>();
            if (ledgeRadius.OverlapCollider(ledgeContact, cols) != 0)
            {
                foreach (Collider2D col in cols)
                {
                    if (col is BoxCollider2D && col.transform.rotation.eulerAngles.sqrMagnitude == 0)
                    {
                        Vector2 point0 = col.bounds.max;
                        Vector2 point1 = (Vector2)col.bounds.max - col.bounds.size.x * Vector2.right;

                        if (ledgeRadius.OverlapPoint(point0))
                        {
                            ledging = true;
                            Ledge(point0);
                        }
                        else if (ledgeRadius.OverlapPoint(point1))
                        {
                            ledging = true;
                            Ledge(point1);
                        }
                        else
                        {
                            Vector2 closestPoint = (point0 - (Vector2)arms[0].position).sqrMagnitude > (point1 - (Vector2)arms[0].position).sqrMagnitude ? point1 : point0;
                            //Vector2 lookAt = (Vector3)closestPoint - arms[0].position;
                            ledge = closestPoint;
                        }

                        armsOut = true;
                    }
                }
            }
            else if (armsOut)
            {
                ArmsDown();
            }
        }
        else if (armsOut)
        {
            ArmsDown();
        }

        //Ledge climbing
        if (ledging)
        {
            if (Input.GetAxis("Vertical") > 0)
            {
                climbing     = true;
                rb.simulated = false;
                animator.SetTrigger("Climbing");
            }
        }

        //Orientation
        if (ledging)
        {
            transform.localScale = ((ledge.x - transform.position.x) > 0 ? Vector3.right : Vector3.left) + transform.localScale.y * Vector3.up + transform.localScale.z * Vector3.forward;
        }
        else if (isOnWall)
        {
            transform.localScale = (wallNormal.x > 0 ? Vector3.right : Vector3.left) + transform.localScale.y * Vector3.up + transform.localScale.z * Vector3.forward;
        }
        else if (isGrounded && Vector2.Dot(groundNormal, Vector2.up) < 0.5)
        {
            transform.localScale = (groundNormal.x > 0 ? Vector3.right : Vector3.left) + transform.localScale.y * Vector3.up + transform.localScale.z * Vector3.forward;
        }
        else if (hori != 0)
        {
            transform.localScale = (hori > 0 ? Vector3.right : Vector3.left) + transform.localScale.y * Vector3.up + transform.localScale.z * Vector3.forward;
        }

        //Falldamage
        if (isGrounded && Vector2.Dot(groundNormal, Vector2.up) > maxGroundAngle)
        {
            if (fallDeathTimer > fallDeathTime)
            {
                GameObject.FindGameObjectWithTag("GameLoop").GetComponent <GameLoop>().RestartLevel();
            }
        }

        if (rb.velocity.y < 0)
        {
            fallDeathTimer += Time.deltaTime;
            animator.SetBool("Fall", true);
        }
        else
        {
            fallDeathTimer = 0;
            animator.SetBool("Fall", false);
        }
    }