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 xeetsh · Jun 22, 2015 at 12:56 AM · unity 5rotationtransformpositionfloat

Accurate placed object's transform messes up on game start

I have a cube:

alt text

That is placed over another cube:

alt text

In the scene they are placed like this:

alt text

As the second cube is kinematic it isn't affected by gravity and acts as ground layer on which the cube lays. If i start the game the cubes transform and rotation messes up like this:

alt text

This shouldn't be that big of a problem but as the cube is affected by forces many times its direction changes massively! The only reason for the occurrence of this problem is Unity's use of floating point variables for the position and rotation. If this really is the problem is there any way to solve this?

Thanks!

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 Xarbrough · Jun 22, 2015 at 01:01 AM

Why exactly do you think this is a problem? Your cube uses Physics, so when the game starts, it falls down a tiny amount and then should come to rest.

The position and rotation values are not at all "messed up" they are just showing that they are, very tiny values much smaller than 0. Shouldn't cause any problems. It's just that in the Physics world, nothing will land exactly at whole increments.

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 xeetsh · Jun 22, 2015 at 01:09 AM 0
Share

But the cube shouldn't fall. It is exactly placed on the plane with no room to fall. And it as well causes problems: I let the cube roll with: rb.AddForceAtPosition(new Vector3(150f, 0f, 0f), Vector3.up); it should roll in a perfect line but after 20 rotations its position.y value (which should be 0 all the time because i only apply force in x direction) is at -0.7841578 due to the $$anonymous$$imal rotation at the beginning.

avatar image Xarbrough · Jun 22, 2015 at 01:21 AM 0
Share

Are you sure its value is at -0.78 and not something much smaller liker -0.784157e-05 or something? I don't think it slowly passes through the other collider. But again, in Physics there is no way to move from exactly point a to exactly point b. There is too much going on...Physics materials friction, colliders and gravity fighting. And if you're moving a cube and slide it on the ground there will always be some jitter because of the sharp collider edges. A perfect sphere collider will roll much softer. If you need perfect results, don't use AddForce, use Translate and kinematic rbs.

avatar image xeetsh · Jun 22, 2015 at 01:31 AM 0
Share

The value is definitely -0.78 the cube in the scene (on start it is centered) looks like this after a few turns:

alt text

The thing is that it would be really hard to work with position and rotation ins$$anonymous$$d of physics because the movement wont look that nice so i don't know any other way. So is there really no way to get around this rotation fluctuations?

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

22 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

Related Questions

Floating-point errors while assigning transforms 1 Answer

Player not facing the mouse correctly 1 Answer

Change object position on trigger enter 3 Answers

How can I modify this rotation code to change how far the object rotates? 0 Answers

postion scale and rotation greyed out and not working 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