• 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 ForceX · Jul 02, 2010 at 03:44 PM · physicsplayeroriginfloatingpoint

Player is origin 0,0,0

I've been having a problem with Floating point inaccuracy, where as the player moves beyond the world 0,0,0, by to much he starts to shake. I've come across a youtube video where the uploader mentions that he has fixed the floating point issue by making the world refrence the player as 0,0,0.

http://www.youtube.com/user/imjinc2k

"FP-precision fix is implemented by translating every physics object in the scene such that the player becomes the origin (0,0,0)"

I know you can override some rigidbodies physics properties in script by.

function Awake()
gravity = 0;
rigidbody.mass = somenumber;
rigidbody.drag = somenumber;

so the rigidbody.drag and .mass are script over rides. Is there a physics.origin over ride?

aka.

function FixedUpdate()
physics.origin = transform.Translate(player)

Is there some documentation on doing this?

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
3
Best Answer

Answer by _Petroz · Nov 10, 2010 at 11:05 AM

The phenomena is known as "Spatial Jitter" here is a paper explaining the problem and possible solutions:

http://www.floatingorigin.com/pubs/thorneC-FloatingOrigin.pdf

In short:

change [the] system from moving [the] person through the solar system to moving the solar system around the person

I figured I would be encountering this problem sooner or later on my current project so I wrote some code. This script detects when the camera is further than 'threshold' units from the origin and moves everything so that the camera is back at the origin. I also set the physics to disable beyond a certain threshold as well. That part of the code is quite crude, I'm not sure if there is a better way to disable physics. When testing I discovered the particles weren't getting moved so I had to do them separately. Hopefully this is useful.

http://www.unifycommunity.com/wiki/index.php?title=Floating_Origin

Please let me know if it can be improved.

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 ForceX · Mar 04, 2011 at 12:16 AM 0
Share

Sorry it took so long for me to respond. This was a perfect solution. I created a slimmer version that only deals with transforms. I posted it below. Thanks for your contribution.

avatar image _Petroz · Mar 04, 2011 at 02:23 AM 0
Share

Glad to be of assistance :)

avatar image
0

Answer by Tetrad · Jul 02, 2010 at 04:00 PM

Not the solution you're looking for, but depending on your needs it might be easier: Have you considered just scaling everything down? Probably by a factor of 10 or 100. Unity generally works best if you assume 1 unity unit = 1 meter, so if your character is a lot larger than that you might run into level FP issues sooner than if he was smaller.

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 ForceX · Jul 02, 2010 at 04:05 PM 0
Share

I have tried to scale things down. Currently my player ship is 1 unity unit in size, and can fly to around Z=1000. If i scale the ship down by .5 then i can only fly to around Z=500. So the scaling and the shaking seam to be proportional to each other.

avatar image yoyo · Dec 09, 2010 at 09:40 PM 1
Share

Yeah, the floating point representation is scale independent -- you get 23 bits of precision regardless of your scale.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

No Collision 3 Answers

Glitchy Movement on Slopes using Character Controller 1 Answer

How do you calculate DeltaX and DeltaZ for a character? 1 Answer

2D 360 degress platformer example needed 0 Answers

Character Controller Component, Gravity/inertia, and Root Motion 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