ok so using a physics ray, it hits the terrain…
I can get the name of the object hit from the hit info.
simple enough… I shoot a crate… the hit->name is “Crate”
I hit the terrain… the name is “Terrain”
But if the ray hits a tree on the terrain, it still returns “Terrain” as the name both in the hit and the collider info…
How can I tell if my ray hit a tree (or rock or whatever) that was sprayed onto the terrain, rather than the terrain mesh name itself ?
thanks
you can’t tell if you hit a tree. trees, detail objects and terrain are all part of the same “system”, at least if you do it like that.
what you would do is take the hit point and check it against the terrain height at that x-z coordinates so you know if it is terrain or not
thanks for the reply
yes that will sort of work,
but I won’t know if its tree or a rock detail object… so if I have to do something based on what the collision hit… I have no way to know…
hmm…
what about texture ? can it give you the texture hit ?
ok, i cast another line down from the initial impct point… if it doesnt hit anything else then the impact was the floor… otherwise a sprayed-on terrain object
Or you could use Terrain.SampleHeight() using the collision point. 8)