// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (animator.GetComponent <Enemy>().PlayerDistance < attackRange) { animator.SetTrigger("AttackTrigger"); return; } int integerDir = enemy.MoveDir; if (enemy.WallTest[(integerDir + 1) / 2] || enemy.CliffTest[(integerDir + 1) / 2]) { enemy.ChangeVelocityX_movement(0.0f); } else { enemy.ChangeVelocityX_movement(enemy.MoveDir * trackSpeed); } frameCounter += 1; if (frameCounter >= maxFrame) { NumeratedDir trackDir = (animatorRoot.position.x - player.transform.position.x > 0) ? NumeratedDir.Left : NumeratedDir.Right; enemy.ChangeDir_movement(trackDir); frameCounter = 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) { // enemy_arrow = Resources.Load<GameObject>("Prefabs/Projectiles/enemy_arrow"); // waitBetweenShots = 1f; // shotCounter = waitBetweenShots; animatorRoot = animator.transform.parent; enemy = animator.GetComponent <EnemyGround>(); player = GameManager.Instance.player; trackSpeed = enemy.trackSpeed; attackRange = enemy.attackRange; NumeratedDir trackDir = (animatorRoot.position.x - player.transform.position.x > 0) ? NumeratedDir.Left : NumeratedDir.Right; enemy.ChangeDir_movement(trackDir); if (enemy.CliffTest[(enemy.MoveDir + 1) / 2] || animator.GetComponent <Enemy>().PlayerDistance < attackRange) { enemy.ChangeVelocityX_movement(0.0f); } else { enemy.ChangeVelocityX_movement(enemy.MoveDir * trackSpeed); } }
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { shotCounter -= Time.deltaTime; if (animator.GetComponent <Enemy>().PlayerDistance < attackRange && shotCounter < 0) { animator.SetTrigger("AttackTrigger"); Instantiate(jollarcher_arrow, enemy.transform.GetChild(0).position, Quaternion.identity); shotCounter = waitBetweenShots; return; } int integerDir = enemy.MoveDir; if (enemy.WallTest[(integerDir + 1) / 2] || enemy.CliffTest[(integerDir + 1) / 2]) { enemy.ChangeVelocityX_movement(0.0f); } else { enemy.ChangeVelocityX_movement(enemy.MoveDir * trackSpeed); } frameCounter += 1; if (frameCounter >= maxFrame) { NumeratedDir trackDir = (animatorRoot.position.x - player.transform.position.x > 0) ? NumeratedDir.Left : NumeratedDir.Right; enemy.ChangeDir_movement(trackDir); frameCounter = 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) { animatorRoot = animator.transform.parent; enemy = animator.GetComponent <EnemyGround>(); player = GameManager.Instance.player; trackSpeed = enemy.trackSpeed; attackRange = enemy.attackRange; NumeratedDir trackDir = (animatorRoot.position.x - player.transform.position.x > 0) ? NumeratedDir.Left : NumeratedDir.Right; enemy.ChangeDir_movement(trackDir); if (enemy.CliffTest[(enemy.MoveDir + 1) / 2] || animator.GetComponent <Enemy>().PlayerDistance < attackRange) { enemy.ChangeVelocityX_movement(0.0f); } else { enemy.ChangeVelocityX_movement(enemy.MoveDir * trackSpeed); } }
// 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) { origin = animator.transform.position; animatorRoot = animator.transform.parent; enemy = animator.GetComponent <EnemyGround>(); patrolRange = enemy.patrolRange; noticeRange = enemy.noticeRange; patrolSpeed = enemy.patrolSpeed; enemy.ChangeDir_movement(NumeratedDir.Left); if (patrolRange > 0) { enemy.ChangeVelocityX_movement(enemy.MoveDir * patrolSpeed); } }
// OnStateUpdate is called on each Update frame between OnStateEnter and O nStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (enemy.PlayerDistance < noticeRange) { animator.SetTrigger("TrackTrigger"); return; } if (patrolRange > 0) { float span = animatorRoot.position.x - origin.x; if ((Mathf.Abs(span) > patrolRange && span * enemy.MoveDir > 0) || enemy.WallTest[(enemy.MoveDir + 1) / 2] || enemy.CliffTest[(enemy.MoveDir + 1) / 2] ) { enemy.ChangeDir_movement(enemy.MoveDir * -1); enemy.ChangeVelocityX_movement(enemy.MoveDir * patrolSpeed); } } }