void Update()
    {
        if (!isGameStart)
        {
            if (HudEvent.isGamepause)
            {
                TapToPlay.SetActive(false);
                return;
            }
            else
            {
                TapToPlay.SetActive(true);
            }
                        #if UNITY_EDITOR
            if (Input.GetKeyDown(KeyCode.Space))
            {
                isGameStart = true;
                TapToPlay.SetActive(false);
            }
                        #endif
                        #if UNITY_ANDROID || UNITY_IPHONE
            if (Input.touchCount > 0)
            {
                foreach (Touch touch in Input.touches)
                {
                    switch (touch.phase)
                    {
                    case TouchPhase.Began:
                    {
                    } break;

                    case TouchPhase.Ended:
                    {
                        isGameStart = true;
                        TapToPlay.SetActive(false);
                    } break;

                    default: break;
                    }
                }
            }
                        #endif
            return;
        }
        //Game pause---------------------------------------------------->
        if (HudEvent.isGamepause)
        {
            playerAction = PlayerAction.Idle;
            playerAnimator.SetInteger("State", 0);
            playerParticleSystem.Stop();
            playerDeadParticleSystem.Stop();
            return;
        }
        //--------------------------------------------------------------->
        //--------------------------->
        //-----------------Check for collision detection
        if (playerAction == PlayerAction.Dead)
        {
            //------->
            if (playerDeadParticleSystem.isStopped)
            {
                playerDeadParticleSystem.Play();
                playerGameObjectHolder.SetActive(false);
                //Clear Particle
                playerParticleSystem.Stop();
                playerParticleSystem.Clear();
            }
            //-------->Update Time
            TimeAddedWhileDead += Time.deltaTime;
            if (TimeAddedWhileDead > TimeToWaitWhileDead)
            {
                TimeAddedWhileDead = 0;
                playerDeadParticleSystem.Stop();
                playerDeadParticleSystem.Clear();
                playerAction = PlayerAction.Idle;
                isGameStart  = false;
                TapToPlay.SetActive(true);
                transform.localPosition = originalPosition;
                playerDirection         = -1;
                playerGameObjectHolder.SetActive(true);
                playerParticleSystem.gameObject.SetActive(false);
                velocity = Vector3.zero;

                //------------------->
                hudEvent.Hud_SetTopHudGameObject(TopHud);
                hudEvent.Hud_TopHudToggle(MainHud);
            }
            return;
        }
        //---------------------------->
        Vector2 input           = new Vector2(playerDirection, 0);
        int     wallDirx        = (controller.collisionInfo.left) ? -1 : 1;
        float   targetVelocityX = input.x * moveSpeed;
        velocity.x = Mathf.SmoothDamp(velocity.x, targetVelocityX, ref velocityXSmoothing, (controller.collisionInfo.below)?accelerationTimeGrounded:accelerationTimeAirborne);
        bool wallSliding = false;
        if ((controller.collisionInfo.left == true || controller.collisionInfo.right == true) && !controller.collisionInfo.below == true && velocity.y < 0)
        {
            wallSliding = true;
            if (velocity.y < -wallSlideMax)
            {
                velocity.y = -wallSlideMax;
            }
            if (timeToWallunStick > 0)
            {
                velocityXSmoothing = 0;
                velocity.x         = 0;
                if (input.x != wallDirx && input.x != 0)
                {
                    timeToWallunStick -= Time.deltaTime;
                }
                else
                {
                    timeToWallunStick = wallStickTime;
                }
            }
            else
            {
                timeToWallunStick = wallStickTime;
            }
        }
        if (this.controller.collisionInfo.above || this.controller.collisionInfo.below)
        {
            velocity.y = 0;
        }
                #if UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (wallSliding)
            {
                if (collideWall)
                {
                    collideWall     = false;
                    playerDirection = playerDirection == 1?-1:1;
                }
                if (wallDirx == input.x)
                {
                    velocity.x = -wallDirx * wallJumpClimb.x;
                    velocity.y = wallJumpClimb.y;
                }
                else if (input.x == 0)
                {
                    velocity.x = -wallDirx * wallJumpOff.x;
                    velocity.y = wallJumpOff.y;
                }
                else
                {
                    velocity.x = -wallDirx * wallLeap.x;
                    velocity.y = wallLeap.y;
                }
            }
            if (controller.collisionInfo.below)
            {
                velocity.y = jumpVelocity;
            }
        }
                #endif
                #if UNITY_ANDROID || UNITY_IPHONE
        if (Input.touchCount > 0)
        {
            foreach (Touch touch in Input.touches)
            {
                switch (touch.phase)
                {
                case TouchPhase.Began:
                {
                    if (wallSliding)
                    {
                        if (collideWall)
                        {
                            collideWall     = false;
                            playerDirection = playerDirection == 1?-1:1;
                        }
                        if (wallDirx == input.x)
                        {
                            velocity.x = -wallDirx * wallJumpClimb.x;
                            velocity.y = wallJumpClimb.y;
                        }
                        else if (input.x == 0)
                        {
                            velocity.x = -wallDirx * wallJumpOff.x;
                            velocity.y = wallJumpOff.y;
                        }
                        else
                        {
                            velocity.x = -wallDirx * wallLeap.x;
                            velocity.y = wallLeap.y;
                        }
                    }
                    if (controller.collisionInfo.below)
                    {
                        velocity.y = jumpVelocity;
                    }
                } break;

                case TouchPhase.Ended:
                {
                    //-------------->
                } break;

                default: break;
                }
            }
        }
                #endif
        velocity.y += gravity * Time.deltaTime;
        controller.Move(velocity * Time.deltaTime);
        collideWall = (controller.collisionInfo.right || controller.collisionInfo.left) ? true : false;
        //Player Action

        if (wallSliding)
        {
            playerAction = PlayerAction.WallSlide;
            playerAnimator.SetInteger("State", 3);
            particleOpener(false);
        }
        else if (collideWall)
        {
            playerAction = PlayerAction.WallCollide;
            if (oplayerAction != PlayerAction.WallSlide)
            {
                playerAnimator.SetInteger("State", 4);
            }
            particleOpener(false);
        }
        else if (!controller.collisionInfo.right && !controller.collisionInfo.left && !controller.collisionInfo.below && !controller.collisionInfo.above)
        {
            playerAction = PlayerAction.Jumping;
            playerAnimator.SetInteger("State", 2);
            particleOpener(false);
        }
        else if (!collideWall)
        {
            playerAction = PlayerAction.Running;
            playerAnimator.SetInteger("State", 1);
            particleOpener(true);
        }
        else
        {
            playerAction = PlayerAction.Idle;
            playerAnimator.SetInteger("State", 0);
            particleOpener(false);
        }
        if (ctemp_playerAction != playerAction)
        {
            oplayerAction      = ctemp_playerAction;
            ctemp_playerAction = playerAction;
        }
        //Change Direction
        if (playerDirection == 1)        //Right
        {
            transform.localScale = new Vector3(scaleData, transform.localScale.y, transform.localScale.z);
            switch (playerAction)
            {
            case PlayerAction.Jumping: break;

            case PlayerAction.Running: particleRotation(270); break;

            case PlayerAction.WallSlide: break;
            }
        }
        else         //Left
        {
            transform.localScale = new Vector3(-scaleData, transform.localScale.y, transform.localScale.z);
            switch (playerAction)
            {
            case PlayerAction.Jumping: break;

            case PlayerAction.Running: particleRotation(90); break;

            case PlayerAction.WallSlide: break;
            }
        }
    }