Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Question How to allow designers to paint boolean areas on terrain in editor that are invisible in game?

Discussion in 'Editor & General Support' started by Bersaelor, Jul 17, 2022.

  1. Bersaelor

    Bersaelor

    Joined:
    Oct 8, 2016
    Posts:
    111
    Hello there,

    I want to allow my level designers to mark certain areas of the terrain with a boolean on/off texture, so they can visually define areas on the terrain.
    There will be procedural generation of assets on the terrain as well as game logic depending on positions, so I need the ability for my level designers to mark areas on the map for future game activity.
    It would be convenient if it worked like the Paint texture feature of the Terrain editor, just with a 1/0 texture that will be invisible in the game , but I need to still be able to query it for whether a point x-y on the terrain is on or off.

    Functionally like drawing districts in CS, just in the unity editor:
    62079-skyline5.jpg

    Ideas I had:
    • Duplicate the terrain object and add a custom editor script that makes sure the 3D-data of all terrains is copied over when one is edited via `change height`. Then give the new terrain object single-color textures for it's texture layers. Add editor-menu buttons to switch between visual view of what the textures the player would see and the logical views for the overlays of logical areas. Make that extra terrain invisible when running the game. How can I programmatically query whether a certain position x/y has an alpha > 0 for a certain terrain layer?
    • somehow add the layers directly on the main terrain, but disable the terrain layers with editor-menu buttons. Not sure if there is a good way to enable/disable layers for terrain objects
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,936
    I like colliders for stuff like this. A paintable area would be awesome and I suppose you could do that with a clone terrain too (that you hide or destroy), but that always seems like beyond the complexity required.

    Grouping the colliders under a meaningful GameObject headers can be useful too, a hierarchy such as :

    MyLevel
    TheTerrainAndAllGeometry
    CollidersWhereYouMaySpawn
    CollidersWhereEnemiesMaySpawn
    CollidersWhereMagicDoesntWork


    And then stick all the GameObjects with colliders under each of those things. This lets you trivially mark them into a layer that is ignored by physics via the collision detection matrix in Physics settings.