• 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 Jufranz · Aug 22, 2011 at 07:23 PM · physics

Force inforamation

Hi, i am new to Unity so maybe this is a very simple question. How do I get the force that is applied to a rigidbody using a box collider? E.g. if the body is in the air the force should be the vector of G.

Tks!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by flaminghairball · Aug 22, 2011 at 07:34 PM

rigidbody.velocity will return the current velocity of the rigidbody.

Comment
Add comment · Show 1 · 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 Jufranz · Aug 22, 2011 at 08:16 PM 0
Share

The velocity is not equal to resultant force that is acting on the body. I need the force so I could send it to a haptic device. Any other suggestion?

avatar image
0

Answer by flaminghairball · Aug 22, 2011 at 08:19 PM

What you might want to do then is create your own rigidbody subclass and just override AddForce to track the acting force.

Comment
Add comment · Show 4 · 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 flaminghairball · Aug 22, 2011 at 08:19 PM 0
Share

I haven't tried that at all though… It could ostensibly cause all kinds of nasty problems. ;)

avatar image Jufranz · Aug 22, 2011 at 08:24 PM 0
Share

That seems what I want. Sorry to ask further more but, where should I start doing that?

avatar image flaminghairball · Aug 22, 2011 at 08:34 PM 0
Share

public class TrackRigidbody : Rigidbody{ public void AddForce(Vector3 force){ //perform your tracking here super.AddForce(force); //call the super implementation } }

Note that it's more complex than that - there are several different 'addforce' functions and modes of adding force that you'll have to take into account. Besides that, this is something of a hacky solution(not to mention one that I haven't tested at all), so it's likely to crash and burn.

avatar image Bunny83 · Aug 23, 2011 at 01:43 AM 0
Share

Actually you can't and you shouldn't derive a class from Rigidbody. Nearly all classes that comes with Unity are sealed since version 2.6 because you shouldn't derive objects from GameObject, $$anonymous$$esh, rigidbody.... Those classes represents very special objects that have it's counterpart in c++.

The only class or component you are allowed to derive from is $$anonymous$$onoBehaviour.

Oh and in C# there's no super.. it's called base.

All the AddForce functions wrap directly to a native C++ function. The gravity is most likely added directly in the engine and would not go through the scripting class.

avatar image
0

Answer by Bunny83 · Aug 23, 2011 at 01:55 AM

The rigidbody component doesn't track the forces. All forces directly affects the velocity and cause a velocity change.

You might be able to calculate the overall force by storing the velocity from the last frame and calculate the difference.

Keep in mind that most forces generated by the physics system are impulse forces and are only applied once.

Note that forces that are applied at a specific point are converted into a force at the mass center and a torque around the center.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

2D 360 degress platformer example needed 0 Answers

Help getting sliding / surfing mechanics with rigidbodies. 0 Answers

OnTrigger outside the trigger and collider gamobject 1 Answer

Why does using the velocity of y for the y velocity value work to simulate gravity? 1 Answer

How to measure the force by which Two rigid Bodies collide? 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