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
1
Question by chemicalvamp · Oct 14, 2011 at 08:56 PM · rotationphysicsrigidbodyvelocitydamping

A way to kill rotation made by rigid body pysics?

I made a simple script that checks if the NPC has line of sight with the player when it enters a trigger and it works great my problem is that as soon as the NPC gets any kind of force applied to it it goes into an uncontrollable spin. Is there a way to stop this from happening aside from removing the rigid body?

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 asafsitner · Oct 14, 2011 at 11:00 PM 1
Share

First you can set angular drag to the object to keep it from spinning forever. You can also use constraints to restrict it's movement and rotation on each individual axis. In addition, you might want to also call rigidbody.maxAngularVelocity on the object to keep angular velocity under check.

http://unity3d.com/support/documentation/ScriptReference/Rigidbody-maxAngularVelocity.html

http://unity3d.com/support/documentation/Components/class-Rigidbody.html

http://unity3d.com/support/documentation/ScriptReference/Rigidbody-angularDrag.html

avatar image chemicalvamp · Oct 14, 2011 at 11:44 PM 0
Share

Yeah I've already explored those, angulardrag does the job, but it also lowers the turn speed of my NPC, constraints stops my NPCs turning all together, maxangularvelocity doesnt slow down or stop the spin without also lowering the turn speed of my npc. In the shortest way i can say it is i want to put something in a function that arrests the spin imparted by physics forces. C# if i can get it :)

1 Reply

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

Answer by aldonaletto · Oct 14, 2011 at 11:07 PM

You can set rigidbody.freezeRotation to true. It's advisable when you use a rigidbody character, or a CharacterController with a rigidbody attached. This doesn't disallow rotations, only prevents physics from control them.

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 chemicalvamp · Oct 15, 2011 at 12:07 AM 0
Share

freezerotation worked similar to constraints and while i could toggle freeze to true and immediatly re-enable them (so my NPC doesnt fall on its face or side) but it doesnt actually stop it from spinning

transform.parent.rigidbody.constraints = RigidbodyConstraints.FreezeAll;

transform.parent.rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;

avatar image aldonaletto · Oct 15, 2011 at 12:16 AM 2
Share

If you just want to damp the angularVelocity, you try a brute force approach:

float damp = 0.9; // adjust the damp factor if necessary

void FixedUpdate(){ rigidbody.angularVelocity = rigidbody.angularVelocity * damp; ... }

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Rotating a moving object 0 Answers

How may I observe expected physical interactions while using Rigidbody.MoveRotation()? 1 Answer

How can I convert velocity/direction to Force? 3 Answers

Velocity powered rigidbody on a moving platform without parenting. 3 Answers

Sum of multiple velocities 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