Hi Im a bit new to List’s and I was trying to store my physicsmaterials in a List for my footstep sounds. When I walk on the physics material it does trigger but only ever triggers the first material in the List and wont trigger the other ones.
public List<PhysicMaterial> footStepPhysicsMaterials = new List<PhysicMaterial>();
void OnCollisionEnter(Collision hit)
{
//groundType = 0;
//Debug.Log("Sim is walking in no defined mateial");
if (hit.collider.sharedMaterial == footStepPhysicsMaterials[0])
{
groundType = 1;
//Debug.Log("Sim is walking in gravel physics material");
}
if (hit.collider.sharedMaterial == footStepPhysicsMaterials[1])
{
groundType = 2;
//Debug.Log("Sim is walking on physics metal");
}
if (hit.collider.sharedMaterial == footStepPhysicsMaterials[2])
{
groundType = 3;
//Debug.Log("Sim is walking on physics Concrete");
}
if (hit.collider.sharedMaterial == footStepPhysicsMaterials[3])
{
groundType = 4;
//Debug.Log("Sim is walking on physics grass");
}
}