Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 psych0d3l1c · Oct 10, 2014 at 09:12 AM · colliderterrainmeshprefabmesh collider

Collider for rocks.

Hi there. Sorry for that my question may be stupid, but I'm a novice to Unity (also sorry for bad english). I'm now making my first scene. It is a forest. And as I added trees by painting them, I made tree colliders by creating prefab with tree model, adding capsule collider to it and replacing the original tree object with my prefab in terrain tree-painting menu. But what about rocks? If I paint them as terrain details (like flowers, grass etc.), they will look different as I exactly want, but will have no colliders. Tried to paint them as trees (with creating a prefab and adding collider to it), but they still had no collider and also look similar. Of course i can add a collider to every place where I have a rock, but I've got like 50-60 rocks in my forest. Any solutions?

Comment
Add comment · Show 2
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 Redeemer86 · Oct 10, 2014 at 09:25 AM 0
Share

Select all rocks in the scene by selecting them in your hierarchy view. Then In your inspector view click add component, select physics, select mesh collider. There are many options in mesh collider when you add it. See what suit your needs.

Red.

avatar image psych0d3l1c · Oct 10, 2014 at 01:11 PM 0
Share

Bored$$anonymous$$ormon, as i wrote in post i tried that, but not working.

Redeemer86, they are not exist in hierarchy as i painted them by terrain tools. Adding rocks one by one as objects will make them look simiral.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by bubzy · Oct 10, 2014 at 09:24 AM

I use something like this, its not a painter, and I'm not entirely sure how the painter works, but this will randomly populate a set area with rocks (drag the model including collider into the "item" field in the inspector and enter the other properties too to customise the item spawns

 using UnityEngine;
 using System.Collections;
 
 public class itemspawner : MonoBehaviour {
 
     // Use this for initialization
     public Transform item;
     public Vector2 spawnAreaBottomLeft = new Vector2(0,0);
     public Vector2 spawnArea = new Vector2(100,100);
     public int spawnQuantity = 10;
     public bool randomSize = false;
     public bool randomRotation = false;
     public bool randomRotationY = false;
     public float offsetY = 0f;
     //public bool dominant = false;
     Vector2 bLeft; //quicker! :D
     public float exclusionZone = 10f;
     //int i = 0;
     public string priorityTag; //when this item is spawned, delete it if it collides with the priorityTag item
 
 
 
 
     public void spawnItems()
     {
         bLeft = spawnAreaBottomLeft;
         for(int i = 0; i < spawnQuantity; i++)
         {
             Transform temp;
             Vector3 tempPos = new Vector3(Random.Range(bLeft.x,bLeft.x+spawnArea.x),0,Random.Range(bLeft.y,bLeft.y+spawnArea.y));
             temp = Instantiate(item,tempPos+new Vector3(0,Terrain.activeTerrain.SampleHeight(tempPos)+offsetY,0),Quaternion.identity) as Transform;
 
             if(randomSize)
             {
                 float _randomSize = (float)Random.Range(1,10)/10;
                 temp.transform.localScale = new Vector3(_randomSize,_randomSize,_randomSize);
             }
             if(randomRotationY)
             {
                 //Quaternion tempRot = new Quaternion(0f,Random.Range(0f,360f),0f,0f);
                 temp.transform.RotateAround(new Vector3(0,1,0),Random.Range(0,360));
             }
             if(randomRotation)
             {
                 temp.transform.localRotation = Random.rotation;
             }
 
             temp.parent = gameObject.transform;
             }
 
 
 
 
     }
     void Start () {
     
 
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 }
 


hope this helps

Comment
Add comment · Show 2 · 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 psych0d3l1c · Oct 10, 2014 at 01:04 PM 0
Share

Thanks, but I dont understand a few things. 1.Should I add this script to my terrain? Or to my rock prefab? 2.It will spawn rocks immediately, or how I'm gonna make it start?

avatar image bubzy · Oct 10, 2014 at 05:10 PM 0
Share

im not being nasty or preachy here, but you should really follow a few tutorials first.

you can attach this to an empty and add the following line in the void Start() function

 void Start()
 {
 spawnItems();
 }

the way I did it was to have a separate scene manager object that referenced and called all of the spawn functions remotely, this is why the function is public

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.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Find right mesh for collider 1 Answer

Box Collider on Trees Are Not Rotating When Painted to Terrain 1 Answer

Character keeps falling through terrain (with colliders) 4 Answers

Terrain Detail Mesh Collisions 1 Answer

Technique to find a mesh intersecting with a primitive solid without using colliders? 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