Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Jack Akkiarto · Mar 14, 2016 at 05:37 PM · randomstartmountains

Create a random Mountain

Hello Community, I wanted to ask, if there is a possibility to create a random mountain at the start of the game. I searched in Google and in this forum, but i couldn't find something i could directly add to the game. I am pretty new here and i am using Unity for just a short time now. Thanks for every help ^^

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 toddisarockstar · Mar 14, 2016 at 09:36 PM 0
Share

thats a pretty complicated question yer asking! the easiest way would be to have a bunch of different mountains allready made and have your game pick a random number for which one to spawn during runtime.

avatar image Jack Akkiarto toddisarockstar · Mar 15, 2016 at 06:25 AM 0
Share

Yeah, i think i will go with this solution.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Graphics_Dev · Mar 14, 2016 at 10:04 PM

Here is a little code I just wrote to do something like this. You assign mountain prefabs to the slots in the script (as many as you want: it's scalable). Next assign your maxs and mins for all axis. Hope this helps ;)

alt text

alt text

 using UnityEngine;
 using System.Collections;
 
 public class MountainPlacer : MonoBehaviour 
 {
     public GameObject[] mountains;
 
     public int randomMountain;
 
     public float xPositionMax;
     public float xPositionMin;
     public float yPositionMax;
     public float yPositionMin;
     public float zPositionMax;
     public float zPositionMin;
 
     // Use this for initialization
     void Start () 
     {
         randomMountain = Random.Range (0, mountains.Length);
 
         Instantiate (mountains [randomMountain], new Vector3(Random.Range(xPositionMin,xPositionMax),Random.Range(yPositionMin,yPositionMax),Random.Range(zPositionMin,zPositionMax)), Quaternion.Euler (Vector3.zero));
     }
 }
 


mountains1.png (51.2 kB)
mountains2.png (230.4 kB)
Comment
Add comment · Show 4 · 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 Jack Akkiarto · Mar 15, 2016 at 06:18 AM 0
Share

Thank you for the fast solution! I think i should really just make some mountains and choose a random one ins$$anonymous$$d of creating a random. Thank you guys for the fast help. Do you still have an idea how it would be possible to make one random? btw, nice script, helped me a lot ^^

avatar image toddisarockstar Jack Akkiarto · Mar 15, 2016 at 06:45 AM 0
Share

well, a common technic for smooth changing ups and downs is using height maps. you would have to look it up to get the details but its basically using a black and white png image and the terrain picks up how dark the pixels are to represent how high the terrain is. i personally would take the approach of creating a random faded texture2D to assign as a height map.

i would start by getting some random locations in your PNG texture for peaks and peak heights. then Loop through all the pixels coloring them based by the distance to the random peaks. it would create a fade effect in your image. its very highly possible but could take much time coding to get your desired affect.

and by the way....cheers to Graphics_Dev's answer!

avatar image Graphics_Dev Jack Akkiarto · Mar 17, 2016 at 05:08 PM 0
Share

I don't really understand your comment...what is the difference between "choose a random one" and "creating a random"? Also what do you mean by "how it would be possible to make one random"? Are you talking about a procedurally generated mountain?

avatar image Jack Akkiarto Graphics_Dev · Mar 18, 2016 at 06:09 AM 0
Share

Oh yes, sorry i meant a procedurally generated mountain. Now that you say it i see my question was bad formulated. Thanks for beeing that patiently :D

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

52 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Initiating random camera on start? 2 Answers

Prevent overlap with Random.onUnitSphere 0 Answers

¿Por dónde empezar en Unity? 0 Answers

Access singleton in OnEnable when it's initialized in Awake 3 Answers

How to make a line of code run once in C#? 1 Answer


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