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 Cjones110 · Aug 24, 2011 at 11:44 AM · rotationphysicsrigidbody

Engine weight Simulation

Hello, I've been running at this for a while now and cannot find the right solution to this issue. (I'm pretty terrible at maths like this!)

basically, I want my car to simulate the weight of an engine whilst in flight (i.e. going over a jump), I want the car to "nose down" to an angle of 40 degrees on the x maximum.

I've used rigidbody.addrelativetorque(100,0,0) and that continues to nose over too much. Then I tried to say "okay, once you're < 40 degrees set the angularvelocity to 0)"

this doesn't appear to work.:

 if (airborne) {

     if (rigidbody.rotation.x < 40) {

     rigidbody.AddRelativeTorque (nosedip);

     } else { rigidbody.angularVelocity = Vector3.zero;}

 } 

"nose dip" is simply a vector3 = (100,0,0)

I'm pretty sure there's a better way to do this, and I've looked into lerps and slerps, and quaternions and such but it's all out of my league!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Waz · Aug 24, 2011 at 12:03 PM

Sounds like you're trying to fake something. You can set the Center Of Mass of a Rigidbody. You may also need to tweak Angular Drag to get what you're after.

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 Cjones110 · Aug 24, 2011 at 03:54 PM 0
Share

Yeah, the car already has a centre of mass, I don't really want to move it forwards in the car as it negatively effects the handling, it'd be a lot of work to tweak the cars properties again to counter the new centre of mass...

avatar image
0

Answer by Rennat · Aug 24, 2011 at 04:54 PM

Sometimes changing the center of mass depending on whether you're on the ground or not can help with realism.

To continue with the way you're doing it now instead of setting the angular velocity to zero you can add force as an impulse or velocity change with the ForceMode parameter.

Using ForceMode.Impulse : javascript:

 // this is the amount of force it would take to stop the current rotation
 var oppositeTorque : Vector3 = -rigidbody.angularVelocity * rigidbody.mass;
 rigidbody.AddTorque(oppositeTorque, ForceMode.Impulse);

I haven't used it but there is also a ForceMode.VelocityChange which I would imagine would work like this

Using ForceMode.VelocityChange : javascript

 rigidbody.AddTorque(-rigidbody.angularVelocity, ForceMode.VelocityChange);
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 Cjones110 · Aug 25, 2011 at 07:55 AM 0
Share

Aha!That looks like what I want (applying the inverse of the angular velocity to effectively make it 0) - I'll give that a go and post my feedback here.

Thanks!

avatar image Cjones110 · Aug 25, 2011 at 08:11 AM 0
Share

hmm, unfortunately, I think there's a problem with my simplistic check of

" if (rigidbody.rotation.x < 40) {"

as it doesn't appear to be triggering.. (not even triggering a debug.log output) - also I notice that if I rotate the car manually around on it's axis the .x will change even if I'm not changing this axis (i.e. if I'm rotating it around .y it moves the .x slightly every now and then)

how would someone limit the angle something could tip to? (imagine a box, I want it to rotate +1 degree until it's at 45 and then stop)

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 Rigidbody with Physics 1 Answer

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

Freezing Rotation and Joints (Swing / Rope) Physics Issues 1 Answer

drag object including free rotation 0 Answers

How to keep rotation from switching between - and + after a 360? 0 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