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
6
Question by runevision · Sep 24, 2010 at 10:03 AM · physicswater

How to create water physics in Unity?

How do I create water physics in Unity?

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

3 Replies

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

Answer by runevision · Sep 24, 2010 at 10:04 AM

First of all what is meant by "water physics"? Water physics is not one specific thing, water can be simulated in many different ways.

Still water (in a container)

Relatively still water contained in a container - for example a swimming pool - is simulated in many games, for example Half Life 2. It simulates light objects like wood floating up to the surface, while heavy objects may sink slowly to the bottom etc. There may also be waves on the surface.

This type of water physics can be simulated in Unity without problems (2.x or 3.x, it doesn't matter), it just requires some scripting with AddForce() and such. Basically, whenever an object is below the water surface, add an upwards force corresponding to the buoyancy of the object. When the player or other objects collide with a floating object, be sure to make the impact use AddForceAtPosition() rather than AddForce() in order to get a realistic floating feel, where object may tip over.

As for adding waves, waves can either use a predefined pattern based on a texture, or sinus functions, or waves can be simulated to reach realistically to disturbances in the water. See this post for the latter.

Particle systems

Another way to simulate water is with a particle system. This can be done in many ways, but one major difference is whether there is any inter-particle influence or not, i.e. do particles have any effect on other particles.

Particle system without inter-particle influence

Without inter-particle influence the water can look quite good while being sprayed, for example from a hose or fountain, but the water will never fill up a volume since the particles will just end up occupying the same space rather than spreading out. It can still work quite well for some uses though.

For example, the "gels" in the upcoming Portal 2 are of this type. There there are hoses that spray out gels indefinitely but it never fills up the room; the volume of the gel just "disappear" when touching a surface, and only leaves an infinitely thin "puddle" that doesn't grow bigger even though more gel is added.

This type of water can be created in Unity without problems. For the particle simulation, the standard particle systems in Unity can be used. If a proper water surface is wanted instead of billboards, look into using meta balls.

Particle system with inter-particle influence

In order to simulate the volume that water occupies, the particles of a particle system need to influence each other. This is generally more advanced and much more processing intensive. It can create spectacular water effects, but it is not really ready for real-time applications yet because it requires so heavy calculations. Some tech demos may boast to have real-time water of this kind, but for real-world use cases it's still out of reach.

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
3

Answer by duck · Sep 24, 2010 at 10:20 AM

Another area not mentioned so far is water physics for wheeled vehicles (i.e. driving through water).

A simple water trick with wheeled-vehicle-based games is to simply increase the drag of the vehicle's rigidbody based on the depth of any wheels which are below water. To add to this, you can adjust the volume and pitch of a water sound effect loop to the same value (adjust the pitch downwards and the volume upwards as the depth increases). And of course to finish the effect, you could add some visual effects like a particle system at each wheel to show a splashing effect.

This can make driving through water feel very realistic, as it seems to pull on the car and give the thick feel of driving in water.

You can see (and hear) this technique in action here: (Offroad Vehicle "Jackal" Training game)

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 SavaTim · Jun 13, 2019 at 01:08 PM

It Can Halp https://youtu.be/W7tur5kpy6I

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

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

1 Person is following this question.

avatar image

Related Questions

Flowing water with a fixed volume 1 Answer

Elementes like in "from dust" 1 Answer

How to create a water current that pushes a floating object 1 Answer

How can I fake buoyancy (floating) with a configurable joint (or with a script)? 3 Answers

How do you make ripples for character in water? 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