- Home /
Dynamic world in Unity
Hello i just found this amazing framework and i have question its possible to generate dynamic world? for example we have island and in database we have that on x=1, y=2, z=5 we have building.
thanks
Answer by duck · Mar 18, 2010 at 10:02 AM
Yes, it's possible. It's a very large subject to cover in a single answer though, however you can:
- Instantiate objects or characters at any position (also read abobut Prefabs).
- Send and recieve information to and from WWW servers
- Create meshes, materials and shaders on-the-fly
- Sculpt, Texture and add foliage to terrain procedurally (although this is undocumented)
Check out all those links above for answers which go into further detail on the subjects. Like I said, it's a big topic :)
Answer by MedianHansen · Mar 18, 2010 at 09:39 AM
Well... if by dynamic you meen randomly generated each time the scene is loaded/the player enters an area, hten yes it's possible. ou should just set the transform position values to random numbers, for an instance:
function Start() { transform.position=Vector3(Random.Range(-10,10),Random.Range(-10,10),Random.Range(-10,10)); }
Keep in mind though, that Random.Range(-10,10) probably shouldn't use -10 and 10 as numbers. Instead of -10, put the lowest number, in which you want the character/building whatever, to be able to be placed, and instead of 10 you should put the highest. If you are not very experienced in random numbers, just use the use-some-numbers-and-try-to-see-if-they-work-and-if-not-adjust-them-method, it usually works pretty fine.
Oh, i thought you meant placing cities and characters randomly in the area, nvm this anwser ^^
Answer by Dwair · Mar 18, 2010 at 09:41 AM
With Instantiate() you can spawn a mesh or prefab you need in any location you want.
You'll probably need to use a tileable mesh for that, and maybe some mesh combiners.
Answer by Xepherys · Oct 23, 2013 at 08:53 PM
I've been considering this from a psuedo-code perspective for a couple of months, and ran across this article today about probabilistic tiles used in Spelunky. It's actually pretty genius, and now that I'm about to set code to editor, I'm thinking using a variety of pre-fab blocks with variations on probabilistic tile-groups is probably the best answer. My goal would be to allow seeding for specific values, and pseudo-randomly generate seeds for new games. Anyway, the link here and the "Part 2" from it have some interesting insight into one method for doing this - no code, just concept.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How can i make artificial gravity for Kinematic Rigidbody? 3 Answers
C# Dynamically add components? 3 Answers
World to Screen 1 Answer
Dynamic Interactive 2d World Map 0 Answers