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 Kannon · May 01, 2012 at 04:33 PM · positioncoordinates

Wrapping the visible world?

I am not entirely sure how to phrase it to get anything useful on google or here, so apologies if this is a duplicate.

To get around co-ordinate space limitations, how would you mass-move things, maintaining relative positions, from, say, -30,000 to +30,000?

Background, to clarify the question a bit: Hacking on what amounts to a research game. If you've played the old game Flatspace (Or any of the X games and SPAZ, smash those together.), think a multiplayer version of that. Looking at Photon for the network side. (No, I'm not insane enough to try to build an MMO solo, just to make that clear. This is a pretentious indie research type of thing.) Edit: For those of you that haven't, top down 2D space-type game.

Basically, the effect I'm going for is akin to Evochron Mercenary or EVE , where it's a very, very large seamless world, at a reasonable scale. (So far, the math seems to work for 1 unit = 10 km). Which works great until you hit the 50,000 in any direction mark, then it gets a bit jittery.

I hit on the idea of dividing space into grids, and just transitioning from -40,000 in grid 0,1 to +40,000 in grid 0,0. But I'm not entirely sure how to do that in Unity, let alone in a multiplayer environment. (To make life a bit easier, and to learn from the mistakes of others, single-player starts a local multiplayer server.) Any suggestions?

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
0

Answer by Bunny83 · May 01, 2012 at 05:01 PM

Well i've never played the games you referenced in your post, so it would be helpful if your could add some basic information:

  • Is it a 3D ego-perspective game?

  • Is it a top-down-perspective game?

  • maybe even 2d?

The easiest way is to devide your world into chunks of reasonable size. For a top-down view game you need only a few chunks around your player. In a 3D world you need some more since you can look further.

Most the case all you need is to move all visible stuff by a certain offset depending on the direction you're moving. Lets say the limit is +- 2000 units. You wouldn't map +2000 to -2000. It's better to map it to 0 so you don't need to switch forth and back when the player flys along a chunk border.

I would use a special script component to mark and find objects that should be translated. With FindObjectsOfType you get a list of all objects with your script attached.

Now you just need somethin glike that:

 //C#
 float ChunkSize= 2000;
 Vector3 currentChunk = new Vector3(0,0,0);
 
 void MoveWorld(Vector3 rel)
 {
     foreach(Transform T in objectsInScene)
         T.position = T.position - rel * ChunkSize;
     currentChunk += rel;
 }
 
 Vector3 difference = Vector.zero - player.position;
 if (difference.x > ChunkSize)
 {
     MoveWorld(Vector3.right);
 }
 elseif (difference.x < -ChunkSize)
 {
     MoveWorld(-Vector3.right);
 }
 if (difference.z > ChunkSize)
 {
     MoveWorld(Vector3.forward);
 }
 elseif (difference.z < -ChunkSize)
 {
     MoveWorld(-Vector3.forward);
 }

Of course you have to define the chunk loading / unloading distance so when a chunk moves out of this area it gets unloaded and also check for new ones that has to be loaded / created.

This example will move you to the center on the specific axis. So when you fly across 2000 in x direction you will be transported to 0. The virtual position is of course:

 Vector3 virtPos = player.position + currentChunk*ChunkSize;
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Position set way off / Different coordinate system problem 0 Answers

AngryBots mobile joysticks position 0 Answers

Event System value of mouse position is wrong. 0 Answers

split vector3 coordinates in to x,y,z 1 Answer

Maya rotation transformation to Unity 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