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
4
Question by amirabiri · May 22, 2012 at 09:07 AM · shaderphysicsworld

How to create a "wrapping" world in Unity?

I am trying to create a "wrapping" ("rolling" / "repeating" etc) game world. In other words when a game object goes beyond the borders of the world I flip its location to the opposite edge.

My problem now is that I want to make this behavior more smooth. This means that for an object that is partially crossing the world border, two things must happen:

  1. The part of the object that is beyond the border must render on the other side (the game is in top-down view).

  2. The part of the object that is beyond the border should collide with other objects on the other side.

A good example to explain what I mean is to think of the "Star Control" games (if you are old enough like me to remember them...).

I have achieved #1 by using additional cameras that do not clear the buffer and have a limited layer mask. However I think that this is somewhat inefficient? Is there a better way to do this? I looked into using shaders but am not sure if this is the right answer? Or is there something else I've missed?

I do not have a solution for #2 yet. I was thinking of using joints and started looking into the custom joint (as the basic ones obviously weren't built for this scenario). I still haven't fully got my head around how the custom joint works. Anyway the question is if this is the right direction, or is there something better that I've missed?


Edit: Perhaps an image will help... :-)

alt text

wrapping world.png (24.7 kB)
Comment
Add comment · Show 14
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 Lo0NuhtiK · May 22, 2012 at 11:06 AM 0
Share

Like Asteroids or Unitroids you mean?

avatar image amirabiri · May 22, 2012 at 12:37 PM 1
Share

Yes exactly

avatar image amirabiri · May 24, 2012 at 11:14 PM 1
Share

Any ideas?

avatar image Eric5h5 · May 24, 2012 at 11:24 PM 0
Share

Unitroids uses 4 duplicate objects, where 3 are offset in a rectangle the size of the screen, and parented to the "real" one.

avatar image amirabiri · May 24, 2012 at 11:33 PM 1
Share

Yes but Unitroids doesn't do physics simulation on these objects does it? These are just sphere trigger colliders moving about.

For rendering purposes I wonder which is preferable - multiple cameras or duplicate objects?

Show more comments

4 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by MrVerdoux · Dec 12, 2013 at 09:39 AM

The real solution is to make it real: make a toroidal universe! Of course that would cause strange physics, a lot of work... but can you imagine the result? No tricks there, your world would really be wraped!!! You would be my hero :)

alt text

http://en.wikipedia.org/wiki/Doughnut_theory_of_the_universe

Comment
Add comment · Show 1 · 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 Mikael-H · Dec 12, 2013 at 10:06 AM 1
Share

Damn you now I simply must make a game with a donut shaped world...

avatar image
2

Answer by p.hufnagl · Dec 12, 2013 at 08:51 AM

1)I had a simelar problem and fround 2 solutions

-)Use a secound camera translated exactly 1 map size away and let them draw over each other. They even move automatically right if you parent them to the player picture of cameras

-)Divide your map into subtiles. when the player comes close to an edge take the last tile behind away and put it in front of him (better solution i think)

2)I can think of one solution:

Make collider just outside your Map (so they get triggered when something showes over the edge). Then you instanziate a Gost object of it on the other side of the map (position - map size).


cameras.png (4.6 kB)
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
avatar image
1

Answer by adept22 · May 22, 2012 at 11:03 AM

I would create a extra instances of your "world" and tile them, as soon as you move from one i would delete the instance of the "world" you just left and create a new instance in the same direction you went to replace...

If that makes any sense?

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 amirabiri · May 22, 2012 at 10:25 PM 1
Share

I understand what you are describing but I don't quite see how it will solve the problem, perhaps I've missed something?

The problem is that an object can interact with "ghosts" of other objects, i.e copies of other objects from the other side. However when a collision occurs I need the original object's physics to be affected, not just its ghost.

In other words I need the results of collisions and other physics events on the ghost to be applied to the origin object ins$$anonymous$$d of the ghost.

avatar image adept22 · May 23, 2012 at 11:41 PM 0
Share

Is there a known fixed number of "collision" objects that will be interacted with? or are they randomly spawned? are they multiple instances of the same object. ie asteroids or all unique objects

avatar image amirabiri · May 24, 2012 at 11:05 PM 1
Share

There is a limited number of objects. They are randomly spawned initially.

avatar image
1

Answer by runonthespot · Dec 12, 2013 at 09:53 AM

Technically, the answer to this is going to require a few things:

  1. 8 copies of the object (complete with rigidbodies, colliders etc) that can wrap, placed half a screen above, beneath, left, right, above left, above right, beneath left, beneath right.

  2. All of those objects to be connected to the central object with joints / constraints. You basically need a rigid joint that holds the objects positions relative to each other (which will also transfer forces applied to one to all of them), and the objects themselves rotations need to be jointed together (not just synced), so that angular velocity applied to each object is applied to all other objects. (perhaps code that, on collision, each frame, syncs the angular velocity?)

  3. Probably some code to ensure that objects outside of the view have their colliders disabled.

It's the physics aspect that makes this so difficult.

Comment
Add comment · Show 2 · 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 amirabiri · Jun 17, 2014 at 07:58 PM 0
Share

In the end (more than a year ago...) this is what we went with. With the exception that I didn't use joints, but simply updated the parent physic's properties on collision. It worked well. I even tested comparisons with normal objects and the "linked" objects (via code) behaved identically.

avatar image dr_vlat amirabiri · Aug 18, 2016 at 12:10 PM 0
Share

Hi! I'm trying to figure out in the same issue (wrapping and collisions), like you did couple of years ago. $$anonymous$$ay I ask, how did you distributed collision data across the 3x3 object grid?

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

13 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

Related Questions

Is it possible to change the shader of collision bodies in editor? 1 Answer

World View Projection in Shaders 1 Answer

Bouyancy timing issue 0 Answers

Help with Liquid Physics2D 0 Answers

2D 360 degress platformer example needed 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