Creating Box Collider On Specific Terrain Textures

Hello,

I know how to get the information of which textures etc are in the Terrain, however for my game purposes I am trying to figure out how to create a box collider for where there is “dirt” for example as a texture as long as there is dirt I do not want to allow my character to move towards it, therefore need to create a collider about 10 units long in Y where the “dirt” texture exists… Any ways of getting this done effectively ?

In the meanwhile I will be brainstorming as well.

Thanks a lot

EDIT: This will be a phone game, therefore I’m not sure raycast is the best way, perhaps a box collider of where the character is and reads the texture its on?

I’d suggest using a raycast in the direction of movement and then work out what is on the terrain in that direction by using the RaycastHit textureCoord to get access to the splat map at the location intersected. You would then look to see how much of the “dirt channel” was present to limit movement.