- Home /
Advice on a method for identifying rock/dirt in 1 mesh/terrain ?
Given a terrain object or a single large terrain mesh which has differently texture materials, does anyone have advice on architecting a way to determine if the collision point is of a particular physics material ?
An example would be I have a desert (plane) and going through the middle is a textured road (gravel). It wouldn't make sense to break the ground mesh up into several parts. I can think of a few ways but none seem elegant or would work in a generalized sense.
Some off the head ideas :
I could have a material map and paint the world and do a texture lookup, but this doesnt extend to things like buildings and trees.
I could have a scripe with an enum attached to every object, but some objects can be made of 2-3 different materials.
Answer by Eric5h5 · Jan 05, 2011 at 10:33 PM
For a Unity terrain, use TerrainData.GetAlphamaps to read the splatmap data. Each pixel then corresponds to a location, and the r/g/b/a values correspond to the four textures.
Your answer
Follow this Question
Related Questions
Best practice for OnTriggerEnter detection 1 Answer
Collision not working 3 Answers
detecting rigidbody collsion with no extra script 1 Answer
Collision detection not working properly with 2D sprites 1 Answer
change material upon collision 1 Answer