Ignoring how this is kinda messy and outdated, I want where it says “targetHit.rigidbody.GetComponent().Hit(damage);” to be able to reference and activate the function of multiple different scripts (such as enemyScript, bossScript, rangedEnemyScript), and im unsure on what the best way to do this is. Does anyone have any ideas on how this could be implemented?
Thanks in advance
I would suggest all your scripts such as EnemyScript, BossScript, rangedEnemyScript use interfaces. Then you can use GetComponent on that interface instead. You can also look into inheritance.
For example, the Player attack class could raise an event in the AttackTrigger method and the enemy, Boss and rangedEnemy classes could have listeners for that event.
Don’t test floating point values for equality, ESPECIALLY floating point values coming out of an internal property getter such as .localScale, where you have no insight into how that number truly comes out or its likelihood to be precisely 1, as opposed to say 1.00001 or 0.9999, both of which would fail the above test.
You should use single-precision constants 0.6f and 0.4f here because by using 0.6 and 0.4 the entire expression is now going to use double precision math, which is nowhere near as performant as single-precision.
Also, those are magic numbers. They probably should be extracted into semantically-meaningful constants, such as: