Unit C# , Check if Varibale == to on colision with 2 objects


i wanna ask maybe a simple q and maybe its hard :slight_smile:

i have a charcter , that dont move …he got 3 diffrent defence states

def1 (int 1) def2 (int 2) def3(int3)

i got 3 kind of Attacks (Atk1,Atk2,Atk3) spread on 19 diffrent Prefabs, that shot at the player from diffrnet positions on the screen each time ( i made a genarator for that )…

now i wanna check , on collision , if the int Def1 is == to Atk1 then do something , if not do something else .

right now i got Rigidbody2d on player , and everyone got coliders…i do simple check for colider and its working ,

i need to find a way to check the hitting enemys ID type :q

how can i do so ?

you can add a enemy script with public value ID to each object that attacks(prefab). In the inpector of each prefab set different ID value. Than on collision enter you can get object.gameObject.GetComponent().ID than compare it to attack at your player class.