• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jorn818 · Nov 02, 2014 at 11:22 PM · terrainterrain-editorterrainsterrain-trees

Terrain Brush for buildings instead for trees bushes etc.

So you can put trees and bushes and rocks on a terrain but is it possible to place a building on my terrain, because I have an Infiniteterrain script that copies the terrain as you walk turns it etc. but the world is kinda boring to explore without buildings (with loot etc) I searched for procedurall building assets but their are no free ones

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MrSoad · Nov 02, 2014 at 11:33 PM 0
Share

I don't see any reason why you cannot add a building to your terrain assets in the same way as you would add a bush or a tree, it's just a mesh at the end of the day...

avatar image jorn818 · Nov 04, 2014 at 07:30 PM 0
Share

Well the problem is if i want for example working doors or item spawnpoint I cant do that because its required to be one whole object Edit: what i mean is you cant have childs

avatar image MrSoad · Nov 04, 2014 at 07:32 PM 0
Share

No that is a different problem...

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by KMKxJOEY1 · Nov 04, 2014 at 07:42 PM

No you cannot have prefabs as your mesh for the terrain editor. What I did to get around a similar problem was code my own editor script that automatically mass placed a prefab for me. These are the related files:

 using UnityEngine;
 
 public class StarPlacementHelper : MonoBehaviour
 {
     public Color starTint;
     public Color starTint2;
     public float minDensity;
     public float maxDensity;
     public Bounds bounds;
     public SpriteRenderer[] stars;
     public Vector2 minSize;
     public Vector2 maxSize;
     public bool randomRotation;
 
     public void Place()
     {
         if (minDensity > maxDensity || maxDensity < 0)
             return;
 
         float xHalfExtent = ((float)bounds.extents.x / 2);
         float yHalfExtent = ((float)bounds.extents.y / 2);
         float zHalfExtent = ((float)bounds.extents.z / 2);
         for (float x = bounds.center.x - xHalfExtent; x < bounds.center.x + xHalfExtent; x += getRandomDensity())
         {
             for (float y = bounds.center.y - yHalfExtent; y < bounds.center.y + yHalfExtent; y += getRandomDensity())
             {
                 //skip factor
                 if (Random.Range(0, 9) > 1) //80 percent
                     continue;
 
                 for (float z = bounds.center.z - zHalfExtent; z < bounds.center.z + zHalfExtent; z += getRandomDensity())
                 {
                     //skip factor
                     if (Random.Range(0, 9) > 1) //80 percent
                         continue;
 
                     int index = Random.Range(0, stars.Length);
                     Color col = Color.Lerp(starTint, starTint2, Random.Range(0f, 1f));
                     SpriteRenderer r = Instantiate(stars[index], new Vector3(x, y, z), Quaternion.identity) as SpriteRenderer;
                     r.color = col;
                     r.transform.localScale = getRandomSize();
                     r.transform.parent = transform;
                     if (randomRotation)
                         r.transform.eulerAngles = new Vector3(0, 0, Random.Range(0f, 359f));
                 }
 
             }
         }
     }
 
     public void DeleteC$$anonymous$$ldren()
     {
         //foreach (Transform t in transform)
         //    DestroyImmediate(t.gameObject);
 
         foreach (SpriteRenderer t in transform.GetComponentsInC$$anonymous$$ldren<SpriteRenderer>())
             DestroyImmediate(t.gameObject);
     }
 
     private Vector3 getRandomSize()
     {
         //we want a square anyways
         float x = Random.Range(minSize.x, maxSize.x) + minSize.x;
         //float y = Random.Range(minSize.y, maxSize.y) + minSize.y;
         //return new Vector3(x, y, 0);
         return new Vector3(x, x, 0);
     }
 
     private float getRandomDensity()
     {
         return Random.Range(minDensity, maxDensity);
     }
 
     void OnDrawGizmosSelected()
     {
         Gizmos.color = new Color(1, 1, 1, 0.3f);
         Gizmos.DrawCube(bounds.center - Vector3.forward * 20, bounds.extents);
     }
 }



 ///////////////
     //place t$$anonymous$$s one inside of an editor folder:
 ///////////////
     using UnityEngine;
     using UnityEditor;
 
 [CustomEditor(typeof(StarPlacementHelper))]
 public class StarPlacement : Editor
 {
     public override void OnInspectorGUI()
     {
         serializedObject.Update();
 
         StarPlacementHelper s = target as StarPlacementHelper;
 
         base.OnInspectorGUI();
 
         if (GUILayout.Button("Populate"))
         {
             s.Place();
         }
         else if (GUILayout.Button("Delete C$$anonymous$$ldren"))
         {
             s.DeleteC$$anonymous$$ldren();
         }
    }
 
     private static void Space(int num = 1)
     {
         for (int i = 0; i < num; i++)
             EditorGUILayout.Space();
     }
 }

Keep in mind that t$$anonymous$$s was for a 2D project, you may have to change up some of the axis to get what you are looking for.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jorn818 · Nov 05, 2014 at 06:44 PM 0
Share

Are these 2 scripts in one since one has to be put in the editor folder? Also isn't it possible to add the gameobjects with lootpoint etc then convert all children to make it one solid single parent object?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

terrain engine with holes 0 Answers

Terrain Issue [Video] 1 Answer

Terrain not appearing shaded unless very close 1 Answer

Terrain matrix 8*8 1 Answer

duplicate terrain and change painted tree asset of only the duplicate 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges