// public GameObject toDestroy; public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { var parent = animator.GetComponentsInParent <Transform>().FirstOrDefault(); // if (parent != null) Destroy(parent.gameObject, stateInfo.length); }
// 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(); }
// 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) { animator.GetComponentInParent <EnemyController2D>().enabled = false; animator.GetComponentInParent <Rigidbody2D>().simulated = false; animator.GetComponentInParent <FireWorm>().healthBar.transform.parent.gameObject.SetActive(false); animator.GetComponentInParent <FireWorm>().enabled = false; var colliders = animator.GetComponentsInParent <CapsuleCollider2D>(); foreach (var collider in colliders) { collider.enabled = false; } }
private void InitAnimators() { Animator[] componentsInChildren = base.get_transform().GetComponentsInChildren <Animator>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Animator animator = componentsInChildren[i]; if (animator.get_enabled()) { FXLOD[] componentsInParent = animator.GetComponentsInParent <FXLOD>(true); if (!this.IsShield(componentsInParent)) { this.m_animators.Add(animator); } } } }
// 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; } }
// 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; }