I was wondering if there is a way to paint on the terrain in game? Im trying to make a tank leave tracks behind but my current way is quite laggy (spawning tracks under me) is there any way to edit the terrains textures in game or edit a meshes?
2 Answers
2Your best bet would probably be a decal system that "paints" on top of the terrain. There is a demo decal system available within the Unity Asset Store and you could make your own. If you are looking to make your own, all you need to do is spawn a texture at the point of collision between the tank's tracks and the ground.
You can paint on the terrain in-game using GetAlphaMaps and SetAlphaMaps, though that may not work well for tank tracks considering resolution issues, as well as not having directional information in the texture (i.e., the orientation of the texture is always the same).
how would I spawn a decal or texture? a gameobject?
– saberboy117You probably want to create a prefab that consists of a single plane with a material attached. Apply the tank tract texture to that material, and than instantiate the prefab through script when the tank collides with the terrain. Or, you could create a plane when the collision happens and than attach the material to the plane when its created. A prefab is probably the more elegant solution.
– anon53210484