I really have no previous experience in this area, but I’m trying to make a script that does this:
-Part is touched
-Part recognizes what terrain material touched it
-Part names itself that terrain material
It’s pretty simple, but it will save me a ton of time because I’ll make a ton of parts fall and paste grass meshes into each of the grass parts, light grass meshes into each of the sand, etc.
There might be a more practical way to do this but here is my idea.
After the touched event
Make several rays fired in a bunch of directions outwards from the part.
A ray can return the position it hit and the material of what it hit, works for terrain materials too. So just compare the distance of the ray hitpoints and find the closest one that makes sense to fire the touched event. To wrap it all up just set the name to the
tostring(material) returned value.
Haha, I don’t know about you, but I think it works pretty good.
Maybe one day somebody will make a plugin
oof I demand 60% of all profits off the plugin
The easier method is to use the position of the part as the origin, and the velocity of the part as the direction. This usually guarentees an accurate description of what object got hit.