I’m also assuming no namespace or controls at the top since it’s a smaller project?
So for this code in AttackDamage :
private void PlayerSelfDamage(Collider2D other) {
if (other.gameObject.CompareTag(playerString)) {
other.GetComponent().TakeDamage(damageAmount);
other.GetComponent().getKnockedBack(transform, knockBackThrust);
}
}
This means :s
private void PlayerSelfDamage(Collider2D other) {
- if player collides with someone that is not player (other)
if (other.gameObject.CompareTag(playerString)) {
This compares the other to Player (identifies it as player? or is that done by the above string?)
other.GetComponent<PlayerHealth>().TakeDamage(damageAmount);
TakeDamage is called, with damageAmount as parameter
other.GetComponent<KnockBack>().getKnockedBack(transform, knockBackThrust);
}
getKnockedBack is called with transform and knockBackThrust as parameters.
How is getKnockedBack called when it’s in another script and not in AttackDamage.CS?
I see that knockBackThrust is defined, but without a value?
Because the method is defined with two parameters, does it always take two parameters? Do they have to be of the type defined?