• 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 GlitchBait · Aug 07, 2012 at 07:49 PM · inertia

Stabilize : remove inertia after collision

I found a solution in C#, but not in java.

In zero gravity, when I collide into an object I retain the inertial spin from colliding into another object. I thought resetting the position would solve this.

Here's what I tried:

if(Input.GetButtonUp("Jump")){

     Debug.Log("Attempting to stabilize yourself");
  rigidbody.rotation = Quaternion.identity;

 }

What function can I user to remove to ongoing torque or inertia from colliding with another object in space...((Perhaps I'm not searching the correct terminology or wordage, as I'm sure I'm not the first person wondering how to solve this issue.))

Comment
Add comment · Show 1
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 telgo · Feb 10, 2016 at 03:17 PM 0
Share

Even though I beleive I understand it, I still dont get something.

I am playing with the TAN$$anonymous$$S tutorial game. When a shell hits, force is applied:

 if (colliders [i].tag == "Zombie") {
         targetRigidbody.AddExplosionForce (m_ExplosionForce,   transform.position, m_ExplosionRadius,1.0f);
         float angle = Random.Range(-110, 100);
         targetRigidbody.transform.Rotate(0,angle,0);
 }

and that's just what I want. In that same OnTriggerEnter code, I call health.TakeDamage() and in that code I detect death and call Death() which plays the animation and audio.

Then in the health.Update I have the code:

 Rigidbody rb = GetComponent<Rigidbody>();
     rb.velocity = Vector3.zero;
     rb.angularVelocity = Vector3.zero;
     rb.inertiaTensorRotation = Quaternion.identity;
     //rb.inertiaTensor = Vector3.zero;
     rb.is$$anonymous$$inematic = true;
     rb.is$$anonymous$$inematic = false;
     Destroy (gameObject,5f);

(note inertiaTensor line gives an error.)

The result is the corpse (for animation) continues to move around. Same if I change Update to Fixedpdate.

3 Replies

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

Answer by ScroodgeM · Aug 07, 2012 at 07:53 PM

rigidbody.velocity = Vector3.zero;

...resets speed

rigidbody.angularVelocity = Vector3.zero;

...resets rotation speed

transform.rotation = Quaternion.identity;

...sets rotation to identity

http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-constraints.html

...can freeze rotation/moving for future collisions

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 Muuskii · Aug 07, 2012 at 07:54 PM 0
Share

Dammit Scroodge! Why are you always that little bit faster than me! xD

avatar image ScroodgeM · Aug 07, 2012 at 08:08 PM 0
Share

i just hurry a lot... it's so much still remains unanswered here... gogogo....

avatar image
0

Answer by Muuskii · Aug 07, 2012 at 07:54 PM

If your want a rigidbody to NEVER rotate on a certain axis (which it sounds like you do) consider using rigidbody constraints which can be accessed through the inspector in the dropdown menu under an objects rigidbody component. Click on freeze rotation for X and Z but not Y. This will give you a character that's always horizontal but can still turn left and right.

Hope this helps, thanks!

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 GlitchBait · Aug 07, 2012 at 08:23 PM

Perfect Scroodged, thank you.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

rigidbody2D with instant max speed and slow stop 1 Answer

Inertia around axis 1 Answer

Working with Physics 0 Answers

Help with rigidbody slowing (inertia dampening) 0 Answers

Wierd Internal Physics problem 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