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 fkgomez · Oct 30, 2014 at 10:32 PM · waterunder-water

2D Water and air physics

Hello,

I'm building a 8bit style 2D side-scrolling game. The character swims underwater and also flies above the water line.

  1. What are the physics that simulate water so that when the character goes under the water line there is some factor of buoyancy and water resistance?

  2. And how do I change the physics when the character transitions from water to air.

I'm attaching a quick mockup to give you guys an idea of what the scene looks like. 50 / 50 air and water.

I'm very new to Unity. So be gentle :)

alt text

wate_line.jpg (47.0 kB)
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 fkgomez · Oct 31, 2014 at 08:47 AM 0
Share

I looked into using this: https://www.assetstore.unity3d.com/en/#!/content/9149

This would be my first time buying something from the asset store. Can I can just pull the code and assign it to my assets?

Any other suggestions?

Thanks

avatar image MrSoad · Oct 31, 2014 at 12:05 PM 0
Share

For physical buoyancy you can take a look at this simple you tube video, the script is short and very effective, it will not apply bouyancy when the object is above the water line(a height var which you can define) :

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

For water resistance play around with the drag settings of the rigidbody, when in contact with water apply the drag(you can use a simple trigger over the water area for this) and when out of the water return the drag settings to normal.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Kiwasi · Oct 30, 2014 at 10:46 PM

I just happen to have finished coding a game based on this exact concept, its currently sitting in the art department for finishing. Look for the launch of Pond Wars within the next month.

Here are the basic ideas. Not everything will be applicable, as my game is more interested in objects floating on the water surface, rather then under the water.

  • Define the surface of the water. Pretty simple if your surface is flat. If you want waves you'll need some more though into this

  • Define what percent of the object is below the surface of the water. I used the bounding boxes on the Collider2D. For more accurate representation I split the collider up into several smaller colliders, this may or may not be required for your application.

  • Add a force upwards (world space) to your RigidBody2D that is proportional to the volume of the GameObject and the percent submerged. Again splitting colliders can help.

  • Set the linear and angular drag proportional to the percent submerged.

There are also some prebuilt solutions on the web.

Let me know if you need more help and I'll put up some pseudo code.

Comment
Add comment · Show 3 · 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 MrSoad · Oct 30, 2014 at 11:52 PM 0
Share

What platforms are you releasing Pond Wars for? I like seeing what the people here have made :D

avatar image Kiwasi · Oct 31, 2014 at 01:12 AM 0
Share

Off topic: Its webplayer for at the moment. Plan is $$anonymous$$ongregate first, Facebook if that works.

If there is real interest in the game from players then I will be working on a 'Online' version. That will have multiplayer networking across the webplayer, iPhone/iPad and android.

I'll put a link on my profile page here when its live.

avatar image MrSoad · Oct 31, 2014 at 02:43 AM 0
Share

Cheers, I look forward to having a look :)

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

Audio isn't playing for some reason 1 Answer

Swimming/Underwater 3 Answers

(Updated) Unity Pro water works on preview, but not on Mac standalone export. 0 Answers

Is the current basic water bugged? 0 Answers

Water Basic Has no texture 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