Exemple #1
0
    //input is handled here.
    private void FixedUpdate()
    {
        if (trig_active)
        {
            if (a_active && a_isEnabled)
            {
                Debug.Log(connectedController.GetControllerName() + "A Trigger!");

                //Should be empty because the jump ability can't be transmitted.
            }
        }
        else
        {
            if (a_active && a_isEnabled)
            {
                Debug.Log(connectedController.GetControllerName() + "A");
                Jump();
            }
        }

        #region Physics Celine


        // MOVING HORIZONTALLY
        moveHorizontal = (Input.GetAxis(connectedController.GetHorizontal()));
        if (grounded)
        {
            rigidBody2D.velocity = new Vector2(moveHorizontal * speed, rigidBody2D.velocity.y);
            charAnimation.SetBool("PlayerWalk", true);
            charAnimation.SetBool("StoodStill", false);
        }
        else
        {
            // If player turns mid-jump
            if (tempMove > 0.01 && moveHorizontal < -0.01)
            {
                rigidBody2D.velocity = new Vector2(moveHorizontal * speed * 0.3f, rigidBody2D.velocity.y);
            }
            else if (tempMove < -0.01 && moveHorizontal > 0.01)
            {
                rigidBody2D.velocity = new Vector2(moveHorizontal * speed * 0.3f, rigidBody2D.velocity.y);
            }
        }

        if (moveHorizontal > -.07 && moveHorizontal < .07)
        {
            charAnimation.SetBool("PlayerWalk", false);
        }

        if (Input.GetAxisRaw(connectedController.GetHorizontal()) == 0)
        {
            charAnimation.SetBool("StoodStill", true);
        }

        if (moveHorizontal < -.25)
        {
            if (graphicsSlot.localScale.x > 0)
            {
                graphicsSlot.localScale = new Vector3(-graphicsSlot.localScale.x, graphicsSlot.localScale.y, graphicsSlot.localScale.z);


                pickupSlot.localPosition = new Vector3(-pickupSlot.localPosition.x, pickupSlot.localPosition.y, pickupSlot.localPosition.z);
            }
        }
        if (moveHorizontal > .25)
        {
            if (graphicsSlot.localScale.x < 0)
            {
                graphicsSlot.localScale = new Vector3(-graphicsSlot.localScale.x, graphicsSlot.localScale.y, graphicsSlot.localScale.z);


                pickupSlot.localPosition = new Vector3(-pickupSlot.localPosition.x, pickupSlot.localPosition.y, pickupSlot.localPosition.z);
            }
        }

        /*
         * if(facingRight) {
         *      graphicsSlot.localScale = new Vector3(1, graphicsSlot.localScale.y, graphicsSlot.localScale.z);
         * }
         * else if(!facingRight) {
         *      graphicsSlot.localScale = new Vector3(-1, graphicsSlot.localScale.y, graphicsSlot.localScale.z);
         * }
         */


        // CLIMBING
        moveVertical = (Input.GetAxis(connectedController.GetVertical()));
        if (climbable)
        {
            charAnimation.SetBool("PlayerWalk", false);
            if (!grounded)
            {
                rigidBody2D.velocity = new Vector2(moveHorizontal * speed / 3, moveVertical * speed);
                audioManager.interactionSound(interactionSounds.stairs);
            }
            else
            {
                rigidBody2D.velocity = new Vector2(moveHorizontal * speed, moveVertical * speed);
            }
        }
    }