void Awake()
    {
        // isAnimating = true;

        // rollAllowed = true;
        layerMask = 1 << 9;

        // This would cast rays only against colliders in layer 8.
        // But instead we want to collide against everything except layer 8. The ~ operator does this, it inverts a bitmask.
        layerMask = ~layerMask;


        input          = new DudeActions();
        ledgeDectector = GetComponent <LedgeDetection>();

        isAirborne = false;
        isHanging  = false;
        isJumping  = false;
        isGrounded = true;

        // input.CharacterControls.Shoot.performed += ctx => ShootBoolet(ctx.ReadValueAsButton());

        input.CharacterControls.ZAxis.performed += ctx =>
        {
            currentMovement.z = ctx.ReadValue <float>();
            currentMovement.Normalize();
            movementPressed = currentMovement.x != 0 || currentMovement.z != 0;

            // HandleWalkAnimation(movementPressed);
            // Debug.Log(currentMovement);
        };

        input.CharacterControls.XAxis.performed += ctx =>
        {
            currentMovement.x = ctx.ReadValue <float>();
            currentMovement.Normalize();
            movementPressed = currentMovement.x != 0 || currentMovement.z != 0;

            // HandleWalkAnimation(movementPressed);
            // Debug.Log(currentMovement);
        };

        input.CharacterControls.Run.performed += ctx =>
        {
            runPressed = ctx.ReadValueAsButton();

            // HandleWalkAnimation(movementPressed);
            // Debug.Log(runPressed);
        };

        input.CharacterControls.Roll.performed += ctx =>
        {
            rollPressed = ctx.ReadValueAsButton();
            // Debug.Log(runPressed);
            // can we just set animation bools here?
            // HandleRollAnimation(rollPressed);
        };

        input.CharacterControls.Punch.performed += ctx =>
        {
            punchPressed = ctx.ReadValueAsButton();
            // HandlePunchAnimation(punchPressed);
        };

        // jump action
        input.CharacterControls.Jump.performed += ctx =>
        {
            jumpPressed = ctx.ReadValueAsButton();
            // HandleJumpAnimation(jumpPressed);
        };

        // ragdoll action started
        input.CharacterControls.Ragdoll.started += ctx =>
        {
            ragdollPressed = ctx.ReadValueAsButton();
            // Debug.Log("button down, val : " + ragdollPressed);
            // HandleRagdollAnimation(ragdollPressed);
        };
        // ragdoll action started
        input.CharacterControls.Ragdoll.performed += ctx =>
        {
            ragdollPressed = ctx.ReadValueAsButton();
            if (!ragdollPressed)
            {
                // Debug.Log("button up, val : " + ragdollPressed);
                // HandleRagdollAnimation(ragdollPressed);
            }
        };
    }
Exemplo n.º 2
0
    void Awake()
    {
        // isAnimating = true;

        // rollAllowed = true;



        input            = new DudeActions();
        ragdollControl   = GetComponent <ragdollControl>();   // turn on and off ragdolling
        motionController = GetComponent <motionController>(); // access motion based info, mostly speed
        ledgeDectector   = GetComponent <LedgeDetection>();

        input.CharacterControls.ZAxis.performed += ctx =>
        {
            currentMovement.z = ctx.ReadValue <float>();
            currentMovement.Normalize();
            movementPressed = currentMovement.x != 0 || currentMovement.z != 0;

            // HandleWalkAnimation(movementPressed);
            // Debug.Log(currentMovement);
        };

        input.CharacterControls.XAxis.performed += ctx =>
        {
            currentMovement.x = ctx.ReadValue <float>();
            currentMovement.Normalize();
            movementPressed = currentMovement.x != 0 || currentMovement.z != 0;

            // HandleWalkAnimation(movementPressed);
            // Debug.Log(currentMovement);
        };

        input.CharacterControls.Run.performed += ctx =>
        {
            runPressed = ctx.ReadValueAsButton();

            // HandleWalkAnimation(movementPressed);
            // Debug.Log(runPressed);
        };

        input.CharacterControls.Roll.performed += ctx =>
        {
            rollPressed = ctx.ReadValueAsButton();
            // Debug.Log(runPressed);
            // can we just set animation bools here?
            // HandleRollAnimation(rollPressed);
        };

        input.CharacterControls.Punch.performed += ctx =>
        {
            punchPressed = ctx.ReadValueAsButton();
            // HandlePunchAnimation(punchPressed);
        };

        // jump action
        input.CharacterControls.Jump.performed += ctx =>
        {
            jumpPressed = ctx.ReadValueAsButton();
            // HandleJumpAnimation(jumpPressed);
        };

        // ragdoll action started
        input.CharacterControls.Ragdoll.started += ctx =>
        {
            ragdollPressed = ctx.ReadValueAsButton();
            // Debug.Log("button down, val : " + ragdollPressed);
            // HandleRagdollAnimation(ragdollPressed);
        };
        // ragdoll action started
        input.CharacterControls.Ragdoll.performed += ctx =>
        {
            ragdollPressed = ctx.ReadValueAsButton();
            if (!ragdollPressed)
            {
                // Debug.Log("button up, val : " + ragdollPressed);
                // HandleRagdollAnimation(ragdollPressed);
            }
        };
    }