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 thundax · Mar 12, 2012 at 07:56 AM · randomproceduralchildrenparenting

Procedural/Random Generation of Solar systems

I'm new to Unity,

My team and I are having some issues establishing a framework for random generation of solar systems. We currently have orbit scripts and use parenting. We basically parent each planet to a star that is a point light with a flare.

What I really need to know is....

If I have all the other scripts which I need to apply to general objects which will be generated, how can I have the main generation script apply those scripts to the generated objects?

For instance, I generate a sun and planets. The planets need to be children of that sun and each needs our orbit script applied to it with settings the are based on its distance from the sun. Same for moons, except they are children of their planet.

Also, Any experienced coders here that want to help with this project are welcome to join the team after I see examples of your work.

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 syclamoth · Mar 12, 2012 at 08:01 AM 1
Share

What language are you coding in? This isn't a recruitment site- go to the forums for that stuff.

avatar image thundax · Mar 14, 2012 at 06:21 PM 0
Share

I'm not really recruiting, that was just an extra tid bit.

C# btw... and thanks!

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by syclamoth · Mar 12, 2012 at 08:02 AM

If you want to add a script to a newly created gameObject, use this:

 NameOfComponent newComponent = newObject.AddComponent<NameOfComponent>();

Then, use some kind of initialisation method if you need to pass specific information to the newly instantiated component.

Comment
Add comment · Show 9 · 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 thundax · Mar 14, 2012 at 06:20 PM 0
Share

So say I have a planet which I want to add the Planet_orbit script to, and the planet is named automatically by its position in the star system.

Also, all Planets have a Planet tag and are in the Planet layer. Is there a way I can apply something to all objects within a layer or with a specific tag?

(Planet Rigel-2 would be a good example.)

Now could you write a specific reference in C#, ins$$anonymous$$d of Java?

We don't use java much, I prefer to keep all our code in C#.

avatar image Eric5h5 · Mar 14, 2012 at 06:42 PM 1
Share

That was C# code. Unity doesn't use Java, it uses C#, Unityscript A$$anonymous$$A Javascript, and Boo.

avatar image TSorbera · Mar 14, 2012 at 06:42 PM 0
Share

You can use this function to find all planets in the scene: http://unity3d.com/support/documentation/ScriptReference/GameObject.FindGameObjectsWithTag.html

avatar image syclamoth · Mar 14, 2012 at 08:31 PM 0
Share

Thanks, Eric. @$$anonymous$$dax- I always code in C# personally, so unless specified otherwise in the question, that's the language my answers will be in. If that were UnityScript, it would look like this:

 var newComponent : NameOfComponent = newObject.AddComponent.<NameOfComponent>();

See, that's very different.

avatar image Eric5h5 · Mar 15, 2012 at 03:03 AM 1
Share

Also, when I say Java I mean JS (JavaScript), I know that's not exacting but they both have Java in or as their name.

Java is not interchangeable with Javascript; they are different languages. Using them to mean the same thing is like saying $$anonymous$$ and $$anonymous$$r gas are the same because they start with the same few letters.

Show more comments
avatar image
0

Answer by tucano · Apr 27, 2012 at 02:12 AM

I am working on a library to generate pseudo random numbers in Unity. May be you are interested in use it/contribute to it:

http://u3d.as/content/tucanosoftware/unity-random/2Sg

Comment
Add comment · 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

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

8 People are following this question.

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

Related Questions

Procedural Generation... 2 Answers

how to procedurally generate submarines with random events on the sub? 0 Answers

Changing the parent's position based on a child's variable 0 Answers

Repeating map generation 0 Answers

How to instantiate prefabs between 2 objects like a path 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