Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by overunity3d · Sep 04, 2011 at 10:13 PM · rigidbodyvector3velocitynormalized

rigidbody.velocity.normalized application

How do I apply the var returned from rigidbody.velocity.normalized to the rigidbody in fixedupdate() to keep the gameobject of the rigidbody moving in the original tumble direction?

I can not use .forward because tumbling is momentum based and not axis based.

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 aldonaletto · Sep 04, 2011 at 10:50 PM 0
Share

Do you want to apply a velocity in the direction the rigidbody is rotating? If the object falls to the left, for instance, you want it to move in that direction too?

avatar image overunity3d · Sep 05, 2011 at 02:59 AM 0
Share

Yes. But to the left would be the direction not on the gameobject axis but the viewers view also. It is tumbling so I have no static axis reference. Rotation would be something good to know also. The gameobject is tumbling randomnly.

Thanks.

1 Reply

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

Answer by aldonaletto · Sep 05, 2011 at 03:42 AM

You can have a vector indicating the horizontal direction it's rotating or tumbling by calculating the cross product of rigidbody.angular.velocity and Vector3.up (the cross product of two vectors is perpendicular to both):

function FixedUpdate(){
  // create a normalized vector in the rotation direction
  var moveDir = Vector3.Cross(rigidbody.angular.velocity, Vector3.up).normalized;
  rigidbody.AddForce(moveDir * force);
}
Is this exactly what you want?
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 overunity3d · Sep 05, 2011 at 03:58 PM 0
Share

In respect to an object tumbling I am more concerned with the direction of travel and not the rotation. While an object is tumbling the axis directions are dynamic and rotating in numerous directions but the direction of travel is still a straight line. It is this straight line I am trying to maintain. While the parent is rotated the straight line of the child gets bent meaning the direction of travel is curved towards a global direction and not within the rotated parent:

http://www.youtube.com/watch?v=Vi4XTYREXv0

As can be seen by the YT the rotation of the parent (the box) causes a change in the force direction but when the box stops rotating the child (the sphere) continues in the original direction of the child and not the rotated direction of the parent. I hope this is clear. At this point the YT only shows the problem. This Unity project is for a physics demonstration of a confined space.

I include this link. I am not concerned with rotational velocity. http://en.wikipedia.org/wiki/Angular_velocity

You mentioned this: rigidbody.angular.velocity Did you mean rigidbody.angularvelocity. I could not find angular by itself with a dot product afterwards.

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

Error on 'velocity = [Vector3].normalized'? 1 Answer

Normalizing vector doesn't give a constant direction. 2 Answers

Can't access the velocity of a rigidbody: 'Rigidbody' does not contain a definition for 'velocity' 1 Answer

Animation or smooth teleportation 0 Answers

Is there a way to stop a rigidbody from moving in a specific direction? 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