ok i’ve got four separate scripts that use collisions, but within those some work and some just dont
1.Projectile behaviour (doesnt do anything apart from making it so that the player can heal, stopped working?)
public void OnTriggerEnter2D(Collider2D collision)
{
if(collision.CompareTag("Enemy"))
{
EnemyHit = true;
PE.PlantEnemyHealth -= BaseDamage; //* PS;
WE.WeakEnemyHealth -= BaseDamage; //* PS;
SE.StrongEnemyHealth -= BaseDamage; //* PS;
EnemyHit = false;
}
if (collision.CompareTag("Healer"))
{
Destroy(this.gameObject);
}
else
{
}
}
2.the start of my garbage dumpster fire code i’m so sorry
this makes it so the enemy attacks disappear when they hit the player or specific player projectiles, partially works
public void OnCollisionEnter2D(Collision2D Collision)
{
if (Collision.gameObject.CompareTag("Healer"))
{
Destroy(this.gameObject);
}
if (Collision.gameObject.CompareTag("Player"))
{
Destroy(this.gameObject);
}
if (Collision.gameObject.CompareTag("Projectile1"))
{
Destroy(this.gameObject);
}
if (Collision.gameObject.CompareTag("Projectile13"))
{
Destroy(this.gameObject);
}
if (Collision.gameObject.CompareTag("Projectile14"))
{
Destroy(this.gameObject);
}
if (Collision.gameObject.CompareTag("Projectile15"))
{
Destroy(this.gameObject);
}
if (Collision.gameObject.CompareTag("Projectile8"))
{
Destroy(this.gameObject);
}
}
3.this would be so much worse but i havn’t got past testing yet, it’s for a school project so it doesnt need to be uber polished lol (player gets damaged here obvs, no work)
public void OnCollisionEnter2D(Collision2D Collider)
{
if (Collider.gameObject.CompareTag("EnemyProjectile1"))
{
PlayerHealth -= 20;
}
}
- im sure your sick of this so i’ll only put a few here, they all work in this script anyway
(enemy taking damage from player works 100%)
public void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Projectile1"))
{
StrongEnemyHealth -= 25 ;
StrongAnimation.SetTrigger("StrongHit");
if (StrongEnemyHealth > -1 && StrongEnemyHealth < 1)
{
StrongEnemyHealth = 1;
}
}
if (collision.CompareTag("Projectile2"))
{
StrongEnemyHealth -= 20;
StrongAnimation.SetTrigger("StrongHit");
// FreezeCheck += 1;
if (StrongEnemyHealth > -1 && StrongEnemyHealth < 1)
{
StrongEnemyHealth = 1;
}
}
if (collision.CompareTag("Projectile3"))
{
StrongEnemyHealth -= 20;
StrongAnimation.SetTrigger("StrongHit");
if (StrongEnemyHealth > -1 && StrongEnemyHealth < 1)
{
StrongEnemyHealth = 1;
}
}
the main blaring issue here is that one, i can’t code, and two for some reason in these scripts parts just stop registering as colliding.
the worst part is that at one point they were all working fine its just gradually become broken, and i genuingly have no idea why.
specifically in 2 (EnemyProjectileBehaviour) the enemies attacks just phase through the player, but when hitting the projectiles in the same collision script it works fine.
another bit that just stopped is in the first script(ProjectileBehaviour) the enemies take damage now but the healer system just doesn’t work at all. phases through like the enemy attacks to the player.
iv’e gone to the lengths of making the enemies, player/healer, projectiles and enemyProjectiles all on different layers which seem to sometimes work but like… doesnt in cases, i knw it’s not the problem as results are the same before and after implementing this.
if you need any more information just lmk, genuinely dumfounded and kind of mad no clue whats going on right now