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
1
Question by SirTimmyTimbit · Feb 04, 2011 at 09:37 AM · scenetilerepeatcityseamless

How do I make a scene tileable?

Hello everyone!

I'm trying to create a city in Unity. I don't want to spend a lot of time on the prototype.

I was wondering if there is a way to assemble a tileable chunk of the city and repeat the opposite edge on the fly if the player approaches an edge. The tileable part would probably be a few city blocks long and wide. This is just to give the player a sense of a never ending city without building one.

I've searched around the questions and LoadLevelAdditive() seems like what I am looking for. Do I just load the scene and as the player reaches one edge of it load the same scene again adjacent to current scene? How would I position it?

Thanks!

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

1 Reply

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

Answer by runevision · Feb 04, 2011 at 09:52 AM

I'm not sure LoadLevelAdditive is the best approach here, since it doesn't handle positioning and it would also mean that your city just keeps on growing.

Instead I would suggest to have 4 instances of the tile block active from the beginning in a 2x2 grid.

A B *

C D

When the player (*) approaches the right side of the 2x2 grid (for example the right side of tile B), move the two tiles at the left (A and C) over on the right, i.e. move them a distance of 2 tiles, effectively shifting the grid by 1 tile:

B * A

 D   C

Same for the other 3 directions. For example, if the player then moves up and appraoches the top of the 2x2 grid, shift the bottom two tiles up.

Before:

* B A

 D   C

After:

    D   C
      *
    B   A

This way you can keep the player within your grid and never need more than 4 tiles active at a time.

Note that this method also works for bigger grid sizes. You could have a 3x3, 4x4, or even 10x10 grid of tiles that constantly shift the rows and columns at the edges of the grid to keep the grid approximately centered around the player.

Update - Technical Implementation Hints

Demonstrating a working solution in code or pseudo-code is beyond the scope of this answer. With a solid understanding of two-dimensional arrays it's not too hard.

If it seems too tricky, I'd suggest to first start with the simpler problem of doing it in 1D: Have a 1D array of active tiles, for example along the X axis.

The "potential world" would be like this

A   B   C   D   E   F   G

And the instanced list would hold X number of those (for example 3):

[C] [D] [E]

If the player moves sufficiently to the right, the whole world is shifted. It would work like this:

The tile in the first cell is destroyed:

[ ] [D] [E]

The first cell copies the tile reference stored in the second cell:

[D] [D] [E]

The second cell copies the tile reference stored in the third cell:

[D] [E] [E]

The new tile is created and stored in the third cell:

[D] [E] [F]

Now the world is shifted by one.

When shifting the other way, the process needs to be done from right to left instead.

Extending this to 2D is not really different - if the process above is for one row in a grid, it just needs to be repeated for each row. Then when shifting vertically, the same procedure is done for a column and repeated for each column.

Comment
Add comment · Show 3 · 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 Jesse Anders · Feb 04, 2011 at 10:18 AM 1
Share

Yup, exactly what I suggested in the OP's cross-post to the forums: http://forum.unity3d.com/threads/76635-How-do-I-make-a-scene-tileable. (@The OP: When posting to both UA and the forums, it's nice if you can cross-link the posts so that people don't duplicate their efforts in answering.)

avatar image SirTimmyTimbit · Feb 04, 2011 at 09:25 PM 0
Share

Sorry about that, I'm a total newb :)

avatar image AnotherTimmyTimbit · Mar 17, 2011 at 08:09 AM 0
Share

I posted a follow up as a solution below. Can't login with SirTimmyTimbit for some reason. I'd really appreciate your help again :)

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

No one has followed this question yet.

Related Questions

Procedural Texturing on Multiple Terrain Mesh 1 Answer

How to repeat a scene in unity3d. 1 Answer

Texture repeat not working! 4 Answers

Snapping models 3 Answers

repeating textures (how to solve it) 3 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