//static PhysicsMaterial2D hbMat; static void DebugPrintObjectOnHit(Collider2D otherCollider, GameObject gameObject) { //if(once) //{ // once = false; // HeroController.instance.superDash.WriteComponentTree( HeroController.instance.gameObject.name +"_Superdash" ); //} //Dev.Where(); if (otherCollider.gameObject.name != debugRecentHit) { //Dev.Log( "Hero at " + HeroController.instance.transform.position + " HIT: " + otherCollider.gameObject.name + " at (" + otherCollider.gameObject.transform.position + ")" + " with layer (" + otherCollider.gameObject.layer + ")" ); debugRecentHit = otherCollider.gameObject.name; } //TODO: something in here throws a nullref if (!HeroController.instance.playerData.equippedCharm_15) { return; } Rigidbody2D body = otherCollider.GetComponentInParent <Rigidbody2D>(); if (body == null) { return; } bool isEnemy = body.gameObject.IsGameEnemy(); if (!isEnemy) { return; } TakeDamageFromImpact dmgOnImpact = body.gameObject.GetOrAddComponent <TakeDamageFromImpact>(); PreventOutOfBounds poob = body.gameObject.GetOrAddComponent <PreventOutOfBounds>(); DamageEnemies dmgEnemies = body.gameObject.GetOrAddComponent <DamageEnemies>(); Vector2 blowDirection = otherCollider.transform.position - HeroController.instance.transform.position; //blowDirection.y = 0f; float blowPower = 40f; dmgOnImpact.blowVelocity = blowDirection.normalized * blowPower; dmgEnemies.damageDealt = (int)blowPower; }
void OnEnable() { if (isFinished == null) { isFinished = DefaultIsFinished; } healthManager = GetComponent <HealthManager>(); body = GetComponent <Rigidbody2D>(); poob = GetComponent <PreventOutOfBounds>(); if (poob != null) { poob.otherLayer = (1 << 8); poob.onBoundCollision -= OnBoundsCollision; poob.onBoundCollision += OnBoundsCollision; poob.onOtherCollision -= OnEnemyCollision; poob.onOtherCollision += OnEnemyCollision; } }