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 The-Oddler · Jul 26, 2012 at 01:31 PM · spaceunits

Space unit size

Hi,

I'm making a space game, and currently I have that one unit in unity is one kilometre. So some objects can have (or will have) an x, y or z value of many thousand, if not millions. So I was wondering, how big can a world become, without getting problems with rounding of numbers and such. Can I keep the 1 unit = 1 kilometre, or would it be wise to change it to 1 unit = 100 or 1000 kilometre or something?

I have a ship, small cruiser, like the Enterprise (or something), but also spacestations, meteorites, ... So my unit's can't be too big either, otherwise the spaceship would have to be too small.

What are your thoughts on this?

Thanks a lot!

-Pablo

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

2 Replies

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

Answer by whydoidoit · Jul 26, 2012 at 01:47 PM

I'd say you are definitely going to have a problem, floats just aren't very precise especially when they get big (or small). If you are going to model the whole of space then you are probably going to have to maintain the actual positions using a much more accurate variable and map that down to real positions when the objects are closer together. You should probably consider storing world coordinates in doubles (or indeed Decimals - I've never tried in Unity, but they are a feature of .NET) then have a script that sets the position of the objects to camera coordinates when they are in range, effectively keeping the camera static and moving the world past it.

Comment
Add comment · Show 6 · 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 The-Oddler · Jul 26, 2012 at 02:36 PM 0
Share

So unity uses floats for the position... Is it possible to make it store it as doubles? I'm not going to make the whole of space, just parts of it, but still those parts are pretty big :P

avatar image whydoidoit · Jul 26, 2012 at 02:38 PM 0
Share

No it isn't - only using the method I suggest here - mapping your own coordinates onto the Unity coordinate system.

avatar image The-Oddler · Jul 26, 2012 at 05:34 PM 0
Share

I'm trying this now, and it works well, though there is one problem. Any ideas how I can position my stuff in the editor itself, beyond the range of a float?

avatar image whydoidoit · Jul 26, 2012 at 06:25 PM 0
Share

$$anonymous$$ark you script as ExecuteInEdit$$anonymous$$ode and it will also happen during the editor sessions. You could check for Application.IsPlaying being false and then reverse the operation too - setting your world/space coordinates equal to the editor ones.

avatar image The-Oddler · Jul 26, 2012 at 07:04 PM 0
Share

Yea, was trying that. And that works, though the IsPlaying stuff isn't really useful, it just show you the coordinates twice then... Now I just set the space coordinates to my editor coordinates on Awake, en then move everything around my ship. That works, my ship is now always on 0,0,0, and everything else moves. I'm still playing around with it but it seems very promissing :D

Show more comments
avatar image
1

Answer by Kryptos · Jul 26, 2012 at 02:48 PM

One technique that is a bit counter-intuitive is to make the world move around the character (instead of the character moving in the world), so that the character stays at position (0,0,0) where the maximum precision can be achieved.

Far away object will suffer precision problem, but since they are far away it is not important.

One drawback of this technique is that it is not possible to mark any object as static. In some cases it is a critical drawback that makes it impracticable.

To do so, you need to put all objects (except your player and camera) under a common parent node (that we will call "root" node). Instead of moving the character when responding to player input, you move that node in the opposite direction (same with rotation).


Now if your world is very big, it is unfeasible to edit a scene where objects are one Light-year distant from each other. What you can do is make some prefab of each space area. Store in a list the real position of theses areas. When the character approaches the position of one area, instantiate the prefab. When it moves away, destroy the instantiated prefab.

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 The-Oddler · Jul 26, 2012 at 03:42 PM 0
Share

Your first solution looks like the same one $$anonymous$$ike gave, or am I missing something? The second seems a good one too, though I won't need that big a world. I think I'm going to go with the first one. So I'm accepting the answer of $$anonymous$$ike, since he was first, though thanks a lot to you too!

avatar image Kryptos · Jul 26, 2012 at 04:06 PM 0
Share

$$anonymous$$y first solution is not the same.

avatar image The-Oddler · Jul 26, 2012 at 05:16 PM 0
Share

How is it different?

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

m/s "Meters" convert to au/s "Astronomical Units" 0 Answers

Can you download unity editor onto a USB device? 2 Answers

Space ship controls locking into place 1 Answer

Box Collider bounce causing rigidbody to change rotation -1 Answers

3d space scene tutorial? 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