Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
jmaster2012

How to randomly generate moons

Question

Hey, I am working on a space exploration game, kind of like civ 5. I want to have each different settlement be a moon, and some have animals and stuff.... BUT ANYWAYS! Is there a way to randomly generate my "moons"? I want space in between them, but not a lot. Thanks!

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

You could make lots of different prefabs (for all the moons) and spawn them randomly I guess, that would give you the most control over what the moons are like

Share this post


Link to post
Share on other sites

  • 0

yeah, but I want them to be a bit close... I guess. But I haven't done randomly generating planets before, how would I do that?

Share this post


Link to post
Share on other sites
  • 0

That's a lot more complicated. But since planets are round, use the default primitive sphere, then randomly select a texture from an array and assign it to the material's main texture.

Share this post


Link to post
Share on other sites
  • 0

for placement, just spawn at a random position form the current planet position.

var planetPrefabs : GameObject[];

var minSquarePlacement;

var maxSquarePlacement : int;

var maxPlanets : int;

var planetNum : int;

function Start()

{

yield WaitForSeconds(1);

if(planetNum < maxPlanets)

{

var nextPlanet = Instantiate(planetPrefabs[Random.Range(0, planetPrefabs.length - 1)], Vector3(Random.Range(minSquarePlacement, maxSquarePlacement), Random.Range(minSquarePlacement, maxSquarePlacement), Random.Range(minSquarePlacement, maxSquarePlacement)), Quaternion.identity);

nextPlanet.GetComponent("scriptName").planetNum += 1;

}

}

If your actually randomly generating its shape then you'll have to generate the its shape after its instantiated. I don't currently have a code for that right now

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

Thanks, but I want to instantiate a lot... and I was thinking that maybe some would have animals or something...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...