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
0
Question by 3dDude · Jul 10, 2010 at 11:43 AM · rigidbodycarfloat

car water floating script help.

hi i have part of a script:

for(i=0;i<wheels.length;i++){ if(water){ if(wheels[i].transform.position.y < waterLevel){ rigidbody.drag = .1; var newVector = Vector3(meshWheels[i].transform.position.x,waterLevel,meshWheels[i].transform.position.z); var wheelsDistance = Vector3.Distance(meshWheels[i].transform.position,newVector); var moveVector = Vector3(0, wheelsDistance, 0); if(wheelsDistance >0){

         rigidbody.AddForceAtPosition(moveVector,meshWheels[i].transform.position);
         }
         rigidbody.drag = 2;
         rigidbody.mass = 1;
         rigidbody.useGravity = false; 
         }
         else{
             rigidbody.useGravity = true;
             rigidbody.mass = 5000;
         }

      }
 }

and it is supposed to make the car float when under the waterLevel. but it is also supposed to make the car stay up straight..... because it adds force at the position of each wheel with the power of the force being the distance from that wheel when in the water. but it dosn't.

any help would be awesome.

Comment
Add comment · Show 6
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 spinaljack · Jul 10, 2010 at 03:53 PM 0
Share

so what happens ins$$anonymous$$d?

avatar image 3dDude · Jul 10, 2010 at 09:18 PM 0
Share

the car floats but does not straighten up when floating.

avatar image cncguy · Jul 10, 2010 at 11:45 PM 0
Share

When you say it doesn't straighten up, what exactly does it do? stay at a fixed rotation or sway all over the show?

avatar image 3dDude · Jul 11, 2010 at 12:35 AM 0
Share

it does not move much at all

avatar image cncguy · Jul 11, 2010 at 08:22 AM 0
Share

have you tried adding a multiplier to the force ie. 10, 100? Just to see if something would happen? When you say it does not move much at all, do you mean it doesn't move or it does move a tiny bit?

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by N1nja · Jul 11, 2010 at 04:39 AM

if you want it to lay on the water.. so that its roof is facing directly up, just get the Up vector, and ensure its facing Up in world space.. just do some rotations based on the difference from the worlds up matrix, and the vehicles up matrix.. might have some funny transitions, but thats just a quick fix I'd do..

if I understand what you're expecting at least.. I'm to tired to really help out with the maths atm though.. but good luck!

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 Novodantis 1 · Jul 25, 2010 at 07:48 AM

I usually find force problems having no noticable effect like this is down to a matter of magnitude. As cncguy suggested, perhaps it's worth putting a multiplier on your force, eg.

var moveVector = Vector3(0, wheelsDistance * multiplier, 0);

where "multiplier' is a var you set earlier, to something like 10 or 100. If it goes mental, no worries, at least it's making a difference. Tweak as necessary :)

You could also try changing the force type to Acceleration or other, as the last argument when calling AddForceAtPosition. Check out the various types of forces here.

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 3dDude · Jul 25, 2010 at 12:52 PM 0
Share

thanks i'll try that.

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

How can I make a jet script? 0 Answers

Is there a script for moving a rigidbody without using a character controller? 1 Answer

My car dont move 1 Answer

Rigidbody makes NavmeshAgent stutter in its movement 2 Answers

Rigidbody car physics.... 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