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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by KleptoKat · Jul 15, 2013 at 09:13 AM · c#colliderrigidbody-collision

AddTorque no longer working when collider is added

I have a space object in my game with gravity disabled, it's not kemantic and has child objects that add torque or forces based on inputs. (Such as gyroscopes and engines). It was all working fine until I added a collider to the space object. Now whenever I try to add torque to object it doesn't respond.

When I add a rigidbody.AddRelativeForce works fine, but the rigidbody.AddRelativeTorque function doesn't show my object as moving whatsoever, which it does when the collider is disabled. I've tried different types of colliders as well (mesh, cylindrical, rectangular) with no different results.

Another odd result is that when you enable the collider and then disable it the torque still doesn't work, while if you disable the collider from the start the AddTorque function works fine.

I've included the code that is related to the gyroscopes, as well as the collision and the working ApplyForce function.

SPACE OBJECT CODE:

     void OnCollisionEnter(Collision collisionInfo) {
         print (collisionInfo.gameObject.name);
         rigidbody.AddForceAtPosition(collisionInfo.relativeVelocity, collisionInfo.contacts[0].point);    
     }
 
     void ApplyForce(Vector3 force) {              //This is for the engine and
         rigidbody.AddRelativeForce(force);    //works fine.
     }
     
     void ApplyRotationalForce(Vector3 torque) {   //This is for the gryroscopes
         rigidbody.AddRelativeTorque(torque);  //and does not work when the
     }                                             //collider is enabled.
     

GYROSCOPE CODE:

 if (Input.GetButton("Pitch")) {
     transform.SendMessageUpwards("ApplyRotationalForce", new Vector3(Input.GetAxis("Pitch"), 0, 0) * strength/10);            
 }

HIERARCHY:

  • Space Object

  • Gyroscope

  • Engine

Has anyone else had a similar problem that they got around?

-- EDIT -- New revelation: When the input is pressed, the rotation fluctuates within 6 degrees, however the space object itself doesn't budge. Could this be a problem with the mesh rendering?

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

Answer by KleptoKat · Nov 24, 2013 at 09:17 PM

Solution found here

Richard Buck:

I also found a sudden change in behavior when I added a collider. I was applying a torque to my Rigidbody to rotate it, but after adding the collider the effect of the torque was massively reduced. I realised that the reason for this is that before the collider was added, the object effectively had a point mass (i.e. zero volume). The collider defines the volume of the object's mass, so after adding it the object's mass was no longer a single point, meaning that a larger force is required to rotate it at the same rate, exactly like the real world (think about pushing someone on a roundabout with them at the center, then at the edge).

Consider using ForceMode.Acceleration to manipulate objects without having to worry about their mass distribution.

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

Answer by mikemalinowski · Nov 24, 2013 at 01:07 PM

Did you ever find a solution to this, i have exactly the same issue.

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

16 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

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Can't get a laser working properly. 2 Answers

CharacterController had no enabled property 1 Answer

Creating a collider in a gameObject using only code 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