Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Ascaria · Dec 20, 2016 at 03:25 PM · spriterigidbody2dcollider2d

2D Physics based rotation looses precision after hours

Hi all,

im trying to develop hill climb racing clone, simple 2d noisy terrain with vehicles and events on it.

While implementing my version of "floating origin" technique for vehicles and terrain, everything seems to be okay, but i noticed one weird behaviour of rotation on my vehicles' wheels.

Test scenario is: I have vehicle. 2D physics, sprites, wheeljoints, circle colliders, classic setup. That is travelling great distances (resetting to 0,0,0 coords after configured distance is reached, maximal limit is 10km) but i do not reset rotation of wheels on that vehicle, because i think it is not necessary.

When game is started, everything works perfectly. But after night of testing while i was sleeping, 2700 kilometers passed and wheels rotated 1.436.170 times, they looses precision, so when im travelling beyond 20kmh wheels do not rotate, and then they rotate about 40kmh while vehicle is going 21kmh. But, vehicle is accelerated only through torque applied on wheels and there is no other way of setting wheel gameobject parameters. Vehicle can still smoothly accelerate, only visible problem is that graphical rotation does not match physical rotation. No jittering or shaking, only graphical rotation seems to stick to rotation speeds of 0kmh 40kmh 80kmh and so on, but nothing in between, and only after travelling for hours.

I have no idea what can potentially cause this. And im trying to understand what can potentially do this and how to avoid this.

PS: i noticed one more weird behaviour now in hinge joint 2d test scenario: I connecting trailer to vehicle by programatically creating hingejoint2d, when they are close enough. HingeJoint2d has reference angle and i need to use this to subtract from angle limits, so trailer can rotate 60 degrees up and down relative to truck independently of angle in which they connect (i understood that reference angle is angle in time of connection creation)

problem: when trailer rotates 360 degrees before connection (looks like rotation was 0 degrees and is actually 0 degrees after full rotation), connecting causes drastical rotation of lighter truck 360 degrees in opposite direction. Somehow after trailer rotation, angle limits on connection, when reference angle subtracted, are 360 degrees below zero, so 60 degrees up and 60 down becomes something like -300 and -420 degrees.

what i can think of possible solutions: problem a) when resetting position, also set rotation like "transform.rotation = transform.rotation % 360 degrees" problem b) referenceAngle = joint.referenceAngle % (2f * pi)

I think they have something in common. Some variable seems to not resetting after full rotation. Any suggestions please? Thx, Ascaria

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

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

OnCollisionEnter2D calls when really no collision 1 Answer

multiple objects on oncollissionstay2d 1 Answer

How do i stop rigidbody2D bounce 1 Answer

Location of RigidBody2D on collision 3 Answers

My character won't collide with walls 2d 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