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 Fkat · Sep 05, 2020 at 08:39 PM · physicsbuoyancy

Get an object to float to the top of water.

Okay, I need for an object that starts out rolling along the bottom of water due to being heavy and then upon loosing mass, float to the top. I've watched videos and read blogs on buoyancy but all of them are how to employ it on object that always float on top of water. I need for the object to switch back and forth between floating and sinking. Any help anyone could give me would be greatly appreciated.

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
Best Answer

Answer by GrandWarlock · Sep 05, 2020 at 08:54 PM

@Fkat First of all, buoyancy and weight are completely unrelated. What is the rate at which it loses/gains volume? Let's call rate r. You can have different rates for gaining and losing, Im just doing a universal one for now. Now lets say you have variable V for volume of the object. We don't need to account for density of the fluid because water's density is 1. Assuming normal gravitation acceleration(9.8 m/s^2). So, in your update method { runs every one second, you can look up how to do that if you dont know //There are better ways to do this part but this is just the way I have at the top of my head if(the game object is in water){ V+=r; (Your Game Object).GetComponent().AddForce(0, 9.8V, 0); }else{ V-=r; } } This may be wrong, I'm not completely sure, but based on what I know about physics this is what I think.

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 Fkat · Sep 05, 2020 at 11:26 PM 0
Share

@GrandWarlock Thank you! I should have known that it was the upward force that needed to increase and that multiplied by the fixed delta time! It especially the absence of the latter that was causing problems. Now I need only stabilize the object when it reaches the surface of the water. Again, thank you!

avatar image
0

Answer by Eno-Khaon · Sep 05, 2020 at 10:30 PM

By its simplest description, buoyancy is a difference of mass between a (typically) liquid and a (typically) solid object, relative to the same space (density).

Based on that, if you know the volume of the portion of the object submerged in the water (100% when completely underwater, 0% when not touching water) and, by extension, its density, the body of water will push the object upward against gravity to balance out the displacement of that water. If the object is less dense than the water (at its current depth, as applicable), it will be successfully pushed upwards against gravity. If the object is more dense than the water, its descent will still be slowed as it displaces the water, but it will continue to sink until it reaches a point where it is no longer more dense than the surrounding liquid (and, since that won't necessarily apply, it would instead be stopped by something solid, like a floor).

In short, this means that by decreasing and increasing the object's mass (and, by extension, its density), the object will rise and fall in the water respectively. If your formula is set up right, then the work is already done for you.

To note, ships are a focal point of buoyancy, so it's not strange to see them emphasized in that regard. Either way, the same logic and formulas generally apply to anything floating (or sinking) in anything else.

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 Fkat · Sep 05, 2020 at 11:28 PM 0
Share

@$$anonymous$$o-Khaon Thank you for your answer. It basically confirmed what GrandWarlock was telling me. If it would allow me I'd mark this as an accepted answer as well.

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

220 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Damping forces to stop boat oscillation 0 Answers

How to Script Buoyancy with a Water Shader 2 Answers

2D 360 degress platformer example needed 0 Answers

Water Ripples 1 Answer

How can I calculate how much of an object has entered a trigger collider? 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