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 josef_matulka · Aug 12, 2019 at 10:46 PM · rigidbodyboxcolliderturning

Box Ridigbody rotates faster left than right

Hey all,

I think I have a pretty straight forward problem.

I have a rigidbody attached to a box collider and I am moving it foward with:

 m_rigidbody.AddForce((((inputAccel * SPEED) * transform.forward) * weight) * Time.deltaTime);

Weight is the actual weight of the rigidbody, SPEED is 2000, and the inputAccel is a float between -1 and 1.

That part seems to work fine, however; my issues come from rotating the rigidbody. Which I do with:

 float angle = Mathf.Lerp(0, 180, Mathf.Abs(turn)) * turn;
 
 Quaternion deltaRotation = Quaternion.Euler(new Vector3(
       0, angle, 0
  ) * Time.deltaTime);
  m_rigidbody.MoveRotation(m_rigidbody.rotation * deltaRotation);

I've tried using AddTorque and I got this code from https://docs.unity3d.com/ScriptReference/Rigidbody.MoveRotation.html

The rigidbody seems to turn sharper when moving along the ground right more so than left.

This issue has been driving me crazy and thank you in advance for the help!

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 Bunny83 · Aug 13, 2019 at 12:10 AM

Have you actually confirmed that your turn value reachest the same value in the positive as well as in the negative area? Keep in mind that you have a quadratic saturation, so a small change when close to 1 or -1 will have a much larger impact on the angle than when close to 0.


Also are you sure you don't have and additional forces? For example the rigidbody could have an angularVelocity in one direction and your manual rotation has to work against it in one direction and is added in the other. Also make sure you don't collide with anything while rotating. If your object sits on the ground and is pushed down by gravity, make sure it's actually aligned with the ground perfectly. If your rotation axis is slightly tilted you may rotate an edge into the ground.


Finally I'd like to note that AddForce with ForceMode.Force (the default) does not need deltaTime and has to be used inside FixedUpdate. That's something we can not verify from your code snippet. The force should be given in newtons. If you have trouble understanding the different force modes, see my answer over here

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 josef_matulka · Aug 13, 2019 at 12:19 AM 0
Share

It's pretty apparent that it turns faster left than right. Not sure of a good way to measure it besides the forces being applied to it.

I have angularVelocity set to 0, but I changed that thinking it would do something. It didn't seem to have an effect?

I actually raycast to the ground and allign to its normal beneath the box to ensure that it's lined-up, I disabled that too to see if it was messing with the rotation. No Effect :(

I manipulate my rigidbody in FixedUpdate as well.

avatar image josef_matulka josef_matulka · Aug 13, 2019 at 02:48 AM 0
Share

You know what it was...

It was the multiplying by the Time.deltaTime...

I went back to addTorque and it works perfectly

Thank you :)

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

149 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

Related Questions

Box collider (with Rigidbody attached) gets stuck into another Box Collider 0 Answers

Rotate Rigid body simple car controlls 1 Answer

OnTriggerExit happens too soon! 1 Answer

Why do I get OnTriggerExit upon collision when a rigidbody is kinematic? (example) 3 Answers

i wanna prevent my collider from falling down flat when climbing slope 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