Hi!
First of all, I don’t know if index is the correct word for this. If it isn’t, please correct me!
Now for the problem. I am working on a footstep system and I need to find the right material the raycast hits. My map is built by tiles using full meshes so floor, walls and roof are all connected. Thanks to this I can not use tags and if I do a simple “check for material, do that if that material equals that” because the materials are in an array. Unfortunately the wall material is in first place and the floor always’ last. So for the the “check material” method to work I need to walk on walls. So how can I check what material I am getting when it is in an array?
This is my code so far.
if (Physics.Raycast(groundCheckTransform.position, -Vector3.up, out groundHit, 0.4f, movementSettings.walkableLayer))
{
Material[] hitMaterial = hit.transform.GetComponent<Renderer>().materials;
}
The code doesn’t do much at all at this stage. It just gets the objects materials and puts it in a array.
Thanks in advance!