private void OnTriggerEnter2D(Collider2D collision) { HealthComponent target = collision.transform.root.GetComponent <HealthComponent>(); if (target != null && !hasHit.Contains(target)) { int direction = 1; if (knockBack != Vector2.zero) { direction = (int)Mathf.Sign(target.transform.position.x - moveHandler.transform.position.x); } Vector2 kb = knockBack; kb.x *= direction; float hitStun = moveHandler.GetHitStun(); if (target.Damage(damage, kb, hitStun)) { hasHit.Add(target); MoveHandler enemyHandler = target.GetComponent <MoveHandler>(); moveHandler.HitEnemy(enemyHandler); if (enemyHandler != null) { enemyHandler.HitDirection = direction; } } } /*EntityController target = collision.transform.root.GetComponent<EntityController>(); * if (target != null) * { * if (!entitiesHit.Contains(target.EntityID)) * { * entityController.HitEnemy(target); * int direction = 1; * if (knockBack != Vector2.zero) * { * direction = (int)Mathf.Sign(target.transform.position.x - entityController.transform.position.x); * } * target.Damage(damage,knockBack*direction); * entitiesHit.Add(target.EntityID); * } * }*/ }