Example #1
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        var character = animator.GetComponentsInParent<MobileAnimationController>()[0];

        if (!character)
        {
            //animator.SetInteger("Attack_ID", 0);
            return;
        }
        
        character.RestAttack();
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        _playerCollider2D = animator.GetComponentsInParent<Collider2D>();
        for (int i = 0; i < _playerCollider2D.Length; i++) {
            _playerCollider2D[i].enabled = false;
        }

        if (DisableGravity) {
            _playerRigidBody2D = animator.GetComponentInParent<Rigidbody2D>();
            _gravitySaved = _playerRigidBody2D.gravityScale;
            _playerRigidBody2D.gravityScale = 0.0f;

            _velocitySaved = _playerRigidBody2D.velocity;
            _playerRigidBody2D.velocity = Vector2.zero;
        }
    }
Example #3
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        var character = animator.GetComponentsInParent<MobileAnimationController>()[0];

        character.resting = false;
    }