Finding What Material Is On The Object Player Collided With.

So I have an array of textures that are randomly assigned to an array of game objects. When the player collides with the object I want the player to collide with a specific texture from the array and then do something.

This code is when the player collides with one of the objects in the array:


As for now it prints no.
If you need more information please ask me and thank you.

you can get the material by using other.material.

and so you can compare it with a set of materials, like this:

foreach(Material material in myMaterials)
       if(material == other.material)

@twosuliman Thank you for replying, I was wondering shouldn’t I be using texture instead of material since the array of textures is what I use to set on the game objects? I know that unity then changes it to the material for example I had a folder of images but then It created a folder automatically of materials of these images.