Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 XxJonas_YTxX · Oct 05, 2021 at 12:39 PM · cameraplanesimulatorshakeposition

Camera starts shaking after 2 minutes of continuous flying!


Hi!

When I start the game in unity, after about 2 min, the camera starts shaking... (it also starts shaking, when I build it!) but not on the fixed cameras! The game I make is a flight simulator (Unity Flight simulator).


The plane flies about 150 m/s = 300KTS


Comment
Add comment · Show 4
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 andrew-lukasik · Oct 05, 2021 at 06:29 PM 0
Share

Flight simulator and rendering or position issues? Sounds like classic floating-point precision issue.

By that time (2$$anonymous$$) you could be somewhere past 18000f units from the origin and this means that float might start to slowly loose precision and cause some issues which are invisible closer to the (0,0,0).

avatar image andrew-lukasik · Oct 05, 2021 at 06:33 PM 0
Share

I've read people writing that this is unity-specific issue, but that is definitely not. This is a consequence of how computers handle floating-point numbers (finite number of bits results in finite precision) and to compensate for that you either need to switch to double3 or/and implement floating origin. Every flight simulator that ever was has it's way of addressing this.

avatar image XxJonas_YTxX andrew-lukasik · Oct 13, 2021 at 08:25 PM 0
Share

@andrew-lukasik Thanks for this useful information! so that means... I've to replace every "float" with double3? I'm not an expert at this! :/

avatar image andrew-lukasik XxJonas_YTxX · Oct 14, 2021 at 04:15 AM 0
Share

No no. It means that you need to implement "floating origin". Start with that. This alone should fix most of the visual issues.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by andrew-lukasik · Oct 14, 2021 at 07:34 AM

Flight simulator and rendering or position issues? Sounds like classic floating-point precision issue.

By that time (2min) you could be somewhere past 18000f units from the origin and this means that float might start to slowly loose precision and cause some issues which are invisible closer to the (0,0,0).

Solution? Implement floating origin. It's basically this:

 using UnityEngine;
 using UnityEngine.SceneManagement;
 
 public class FloatingOriginCentral : MonoBehaviour
 {
     public Vector3 Origin = Vector3.zero;
     [SerializeField][Min(1)] float _threshold = 100f;
     void LateUpdate ()
     {
         Vector3 camPos = Camera.main.transform.position;
         if( camPos.magnitude>_threshold )
         {
             Debug.Log($"Origin changed by ( {camPos.x} , {camPos.y} , {camPos.z} )");
             Origin += camPos;
             for( int z=0 ; z<SceneManager.sceneCount ; z++ )
                 foreach( GameObject go in SceneManager.GetSceneAt(z).GetRootGameObjects() )
                     go.transform.position -= camPos;
         }
     }
 }

credits for this neat root iterator idea: https://web.archive.org/web/20210507024450/https://wiki.unity3d.com/index.php/Floating_Origin

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

199 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image

Related Questions

Camera with Target Texture. 1 Answer

How to pan-rotate camera transform parallel to its view plane? 1 Answer

largest reasonable camera view distance? 1 Answer

Plane / Decal Flashes With Player / Camera Movement 1 Answer

Showing what the Camera sees on a plane 1 Answer


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