Get Object ID upon collision.

What I want is for the player to have a separate object/objects for “Hitboxes” and when the enemy collides with them, to get the ID of the hitbox they collided with and to call its variables such as “Damage” “knockback” “Elemental Attribute” and stuff such as that. Also to use its ID to do its own “Am I getting hit by the same hitbox” check during its update phase, so that an enemy is invulnerable to getting hit by the same attack multiple frames in a row.

How would I go about getting the ID of the object they just collided with?

The exact request is :


Here is some code I use similar to what you need

Vector3 trajectoryHitBox=HitBox-this.transform.position;
					RaycastHit[] hitinfo;

					foreach(RaycastHit hitlocal in hitinfo)
						Debug.Log(" explo check id colli "" victim ";
								hitpoint--;//in anticipation of the incrementation

Best regards