// Update is called once per frame
    void Update()
    {
        if (GetComponent <NetworkView>().isMine&& playerControllable)
        {
            float movement          = Input.GetAxis("Horizontal");
            float climbingDirection = Input.GetAxis("Vertical");

            if (animationTimeLeft <= 0)
            {
                bool canDodge = Time.time > timeOfLastDodge + dodgeRechargeTime;
                if (Input.GetButtonDown("DodgeLeft") && isOnGround && canDodge)
                {
                    facingRight = false;
                    rb.AddForce(-dodgeForceVector);
                    isDodging = true;
                }
                else if (Input.GetButtonDown("DodgeRight") && isOnGround && canDodge)
                {
                    facingRight = true;
                    rb.AddForce(dodgeForceVector);
                    isDodging = true;
                }
                else
                {
                    if (movement < 0)
                    {
                        facingRight = false;
                        if (hasTileInFront && isOnGround && !canClingToWall)
                        {
                            rb.AddForce((-moveForceVector + moveSlopeExtraForceVector) * Time.deltaTime);
                        }
                        else
                        {
                            rb.AddForce(-moveForceVector * Time.deltaTime);
                        }
                        movementAttempted = true;
                    }
                    else if (movement > 0)
                    {
                        facingRight = true;
                        if (hasTileInFront && isOnGround && !canClingToWall)
                        {
                            rb.AddForce((moveForceVector + moveSlopeExtraForceVector) * Time.deltaTime);
                        }
                        else
                        {
                            rb.AddForce(moveForceVector * Time.deltaTime);
                        }
                        movementAttempted = true;
                    }
                    else
                    {
                        movementAttempted = false;
                    }

                    if (climbingDirection > 0 && grappleManager.grappleIsOut && !grappleManager.beingRetracted && grappleManager.kunai.isStuck)
                    {
                        if (Time.time > lastPulledInTime + ropeSegmentPullTime)
                        {
                            lastPulledInTime = Time.time;
                            grappleManager.PullInRope();
                        }
                    }
                    else if (climbingDirection < 0 && grappleManager.grappleIsOut && !grappleManager.beingRetracted && grappleManager.kunai.isStuck)
                    {
                        if (Time.time > lastLetOutTime + ropeSegmentLetOutTime)
                        {
                            lastLetOutTime = Time.time;
                            grappleManager.LetOutRope();
                        }
                    }

                    TryClingToWall();

                    if (Input.GetKeyDown("space"))
                    {
                        if (jumpsUsed < maxJumps)
                        {
                            if (!isOnGround && !isGrabbingWall)
                            {
                                if (jumpsUsed == 0)
                                {
                                    jumpsUsed = 1;
                                }
                            }

                            GetComponent <NetworkView>().RPC("PlaySFX", RPCMode.All, (int)playerSounds.Jump);
                            if (jumpsUsed > 0)
                            {
                                if (rb.velocity.y < 0)                                //double jump will cancel downward momentum
                                {
                                    rb.velocity = new Vector2(rb.velocity.x, 0);
                                }
                                rb.AddForce(jumpForceVector * 0.5f);
                            }
                            else
                            {
                                rb.AddForce(jumpForceVector);
                            }
                            ++jumpsUsed;
                        }
                    }
                }
            }

            if ((!facingRight && transform.localScale.x > 0) || (facingRight && transform.localScale.x < 0))
            {
                GetComponent <NetworkView>().RPC("SwitchDirection", RPCMode.All);
            }

            //Animator state checks
            if (Mathf.Abs(rb.velocity.x) > minSidewaysMoveAnimationSpeed)
            {
                isMoving = true;
            }
            else
            {
                isMoving = false;
            }


            TriggerAnimationTransition();
        }
        else
        {
            enabled = false;
        }
    }