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 Ryder · Jun 06, 2010 at 05:24 PM · physicsrigidbodydrag

Changing rigidbody drag based on deviation of rigidbody heading to its direction

Hi all... More physics! (day 2 for me using Unity.. it rocks)

When you throw a dart point first, the drag on it is low. If you throw it with the point 90 degrees to the target it presents a different cross section to the air, and the drag increases.

I need Unity to understand this a little better, so I figured I could change rigidbody.drag based on the difference between heading and direction of movement.

Would I be subtracting Vector3's to get a difference? How then to convert that to simple degrees of deviation?

Conceptually simple... I think :) But in the end, euler degrees deviation is what I am searching for.

Thank you all so much!

Ryder

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 Ryder · Jun 06, 2010 at 10:41 PM 0
Share

$$anonymous$$aybe I should break this down... it may help.

I think that either I need TWO ROTATIONS or TWO VECTORS which represent the direction of travel of the object, and then the heading of the object.

How does one access the direction component of a vector? (by normalizing it?) But then it's confusing again, because the "heading" of the object is a quaternion... and I don't know how to convert that to a normalized vector. But once I have both (expressed as a pair of rotations, or a pair of vectors), there are functions to get the delta angle out.

So confused...

2 Replies

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

Answer by Ryder · Jun 08, 2010 at 06:31 AM

Ok, here is the answer... Thanks to Flynn in forums for the assist!

All you need is to get the degress of deviation from the oriention of the object to its velocity...

var dif = Vector3.Angle(rigidbody.velocity,transform.up); 

(This assumes that forward is in a positive Y direction in the rigidbody's local space)

once you have the deviation in degrees, you can perform any math on it to get a new drag value.

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 AndrewS 1 · Sep 06, 2010 at 04:51 AM 0
Share

Thanks for answering your own question for us. I'm just starting out with Unity and I want to simulate aeroplane behaviour with the physics engine. I gather from your posts that the drag of an object is constant (ie entirely independent from the object's shape, orientation, velocity etc). Is this correct?

avatar image
1

Answer by qJake · Jun 06, 2010 at 08:34 PM

You'd probably want to do something like this:

// Set this to be the "maximum drag", i.e. when
// the object is facing the wrong direction completely (rotation 180). 
float maxDrag = 1;
// Offset angle is how much the object has // rotated from "zero" in either direction, from 0 to 180. float offsetAngle = (transform.eulerAngles.y + 180) % 180;
// Calculate ratio float drag = (offsetAngle / 180) * maxDrag;
// Set drag here rigidbody.drag = drag;
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 Ryder · Jun 06, 2010 at 10:10 PM 0
Share

Thanks SpikeX, this looks pretty good to me, although I can't see where the actual direction of the body is taken into account... (rigidbody.velocity) I see the object heading in the transform, so that is half of it.

I think we still need to divine two vector "directions" (the transform and the velocity) and compare them in a euler form (the degrees of separation) between the two vectors. Once we have degrees between the two, the rest is trivial.

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

No one has followed this question yet.

Related Questions

drag object including free rotation 0 Answers

Is there any way to apply drag to a 3d rigidbody in only 1 direction? 2 Answers

Touch controlled ice puck 0 Answers

Drag a rigidbody2D around scene 2 Answers

Add force based on drag speed 4 Answers


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