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 Wrymnn · Sep 28, 2014 at 09:34 AM · notworkingaddtorque

Why isn`t my 2D AddTorque working?

Hello I have this C# script attached to player in Fixed Update:

 rigidbody2D.AddTorque(Input.GetAxis ("Horizontal") * 5f);

It just won`t work. AddForce works and everything else in that script just not this.

What I have tried so far:

 if(Input.GetButton("Horizontal"))
      rigidbody2D.AddTorque(5f);

Even this won`t work in Update without any key check:

 rigidbody2D.AddTorque(5f);


Yes script is attached, Yes object has Rigidbody2D. As I said, AddForce works, just torque not. Is Kinematic and Fixed angle are Checked OFF.

Please help I am getting hopeless.

Comment
Add comment · Show 2
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 Baste · Sep 28, 2014 at 09:53 AM 0
Share

There's two possible reasons I can think of off the top of my head:

1: The rigidbody2D is kinematic. Then physics (such as torque) won't be applied to it

2: The rigidbody2D is has fixed angle turned on. In that case, it won't be rotated by torque

avatar image Wrymnn · Sep 28, 2014 at 11:09 AM 0
Share

Nope, both are checked OFF.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Wrymnn · Oct 06, 2014 at 01:35 PM

THE SOLUTION:

2D addTorque is bugged.

When you do this:

 public float rotationSpeed; //And now you assaign it in inspector
 void FixedUpdate()
 {
      rigidbody2D.AddTorque(Input.GetAxis ("Horizontal") * rotationSpeed);
 }

It won`t work. Because it`s bugged. But when you don`t assaign it in the inspector, it works fine.

 void FixedUpdate()
 {
      float rotationSpeed = 5.0f; 
      rigidbody2D.AddTorque(Input.GetAxis ("Horizontal") * rotationSpeed);
 }

This works. At least for me.

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 brentshermana · Nov 16, 2015 at 12:43 AM 0
Share

Had the exact same problem and solution. Thanks so much for posting! (You would think the people over at Unity would have fixed something like this by now...)

avatar image nicmarxp · Nov 05, 2020 at 01:03 PM 0
Share

I still have this problem, Unity 2020.1. How should I fix it, so I can change the value from the inspector? Hard coding a value works, just like you wrote here, but I don't think it's an ideal solution :)

avatar image
0

Answer by unimechanic · Sep 29, 2014 at 07:35 PM

Maybe the value calculated with " Input.GetAxis ("Horizontal") * 5f " is too small for the mass of the object, try a very large one.

Also call WakeUp after adding the torque: http://docs.unity3d.com/ScriptReference/Rigidbody.WakeUp.html

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 Wrymnn · Sep 30, 2014 at 05:35 AM 0
Share

No I think 2d add torque is a bit bugged.

But I solved my problem. Ty.

avatar image MorrisIO · Oct 06, 2014 at 10:22 AM 1
Share

$$anonymous$$ind sharing HOW you solved your problem, Wrymnn?

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

29 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

Related Questions

OnSerializenetworkView not doing anything?? 1 Answer

troble with the Axis in unity 1 Answer

OnTriggerEnter not working 0 Answers

Bought asset on the asset store and now cannot download it 1 Answer

SetColor 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