private void Start() { GameObject boss = GameObject.FindWithTag("Boss"); BasicBoss bossScript = boss.GetComponent <BasicBoss>(); health = bossScript.Health; health.OnValueChanged += OnValueChanged; healthBar.maxValue = health.CurrentValue; healthBar.value = healthBar.maxValue; nameTag.text = "Bad Cylinder"; }
//Function to spawn a 2d ray to hit enemy void ProcessCollision() { //Go through held attack damage stuff if (SpawnHitBox && SpawnHitBoxTimer <= 0.0f) { SpawnHitBox = false; Collider2D enemy = null; Vector2 spawn_position = new Vector2(transform.position.x + HeldAttack.center_distance.x, transform.position.y + HeldAttack.center_distance.y); if (HeldAttack.collider_type == AttackObject.ColliderType.Box) { //Debug stuff DebugHitBox(Color.red); enemy = Physics2D.OverlapBox(spawn_position, HeldAttack.size, HeldAttack.angle, LayerMask.GetMask("Enemy")); } else if (HeldAttack.collider_type == AttackObject.ColliderType.Circle) { //Debug stuff DebugHitCircle(Color.red); enemy = Physics2D.OverlapCircle(spawn_position, HeldAttack.radius, LayerMask.GetMask("Enemy")); } if (enemy != null) { Debug.Log("HIT"); BasicBoss boss_health = enemy.GetComponent(typeof(BasicBoss)) as BasicBoss; boss_health.Health -= HeldAttack.damage; Debug.Log(boss_health.Health); } else { Debug.Log("Miss"); } } }