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 adelphiaUK · Jan 03, 2015 at 01:15 PM · particlesystemconstraintsfillfluid

"Filling" an object with fluid

I am working on a game that requires a conical flask to be "filled" with a fluid. However, I'm struggling how to accomplish it. The game is in 3D so a 2D plane is not applicable in this case.

I have tried using a particle system but I don't think I understand the particle system well enough to be able to do what I'm after.

Are there any tutorials that anyone knows of which shows how to "fill" an object internally, like a glass of wine or does anyone know how to do it themselves and are willing to share?

I have found several videos YouTube which show what I'm after, but unfortunately, they have no links on how to do it.

If you take a look at this example, the effect I'm after is the filling of the glass. The pouring of the wine is documented and explained, but I can not for the life of me figure out the all important container filling part.

Any help appreciated, as always.

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

Answer by tanoshimi · Jan 03, 2015 at 01:30 PM

Real-time fluid dynamics is very complex. There's an interesting research paper (although now over 10 years old) at http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf

Why do you need the object to be filled? Just for graphical effect, or does it have some impact on the game logic (i.e. do objects need to float on the water surface?)

Comment
Add comment · Show 7 · 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 adelphiaUK · Jan 03, 2015 at 03:16 PM 0
Share

Thanks for your response. The reason I need the object filled is that it's what the game is all about. You have to collect a series of "raindrops" in a bucket and fill the conical flask with what you collect in the bucket. I have the conical flask all ready to go but I just can't figure out how to "fill" it. Do you think it might be possible to do this some other way, like using Alpha Cut-off and a texture although I don't see how this can be used in 3D. The flask is purely a gauge but I don't want to switch to 2D as this will change what I plan to do with the game.

avatar image tanoshimi · Jan 03, 2015 at 04:14 PM 1
Share

Well, if it's just a gauge for graphical effect, you could have a 3d mesh for the liquid which sits inside your conical flask and apply a shader that masks it using the stencil buffer. Then, as you want the beaker to "fill", gradually change the values in the buffer to reveal more of the liquid. This could either be aligned to the base of the flask or, if the flask were tilted, to the world normal ins$$anonymous$$d.

avatar image adelphiaUK · Jan 03, 2015 at 07:21 PM 0
Share

This is one thing I was looking at but I'm a bit unsure how to create my solid "fluid" object (I'm not that clever with 3DS $$anonymous$$ax) and I've not even touched on the shader side of things. Is this the sort of thing you mean?

avatar image tanoshimi · Jan 03, 2015 at 07:26 PM 0
Share

Yes - that uses an alpha cutoff shader rather than a stencil buffer, but it's essentially the same result. You said you already have the conical flask object, so to create the liquid mesh just shrink that a bit and place it inside the flask.

avatar image adelphiaUK · Jan 03, 2015 at 08:45 PM 0
Share

Tried that with the fluid but the fluid has to be solid and that's where I'm falling down. I can't figure out how to make it solid. I've tried researching but that suggests to use extrude which will take an earth of time! I guess I need to concentrate on one thing before another and maybe I'm trying to do too much too fast. Perhaps I need to make it a 2D game rather than 3D and change how I am going about it.

Show more comments
avatar image
0

Answer by Mmmpies · Jan 03, 2015 at 02:07 PM

That video has the source code at the bottom of it although it looks like you have to give them your email address at least to download it.

Really though all you need is some trigger colliders attached to the bottle that can be setActive when pouring. If the collider is hitting the glass then fill the glass.

As @tanoshimi say's full fluid dynamics is really complex but if you just want the glass to fill then that should allow you to spot when the glass is under the stream of liquid.

It get's more complex if the bottle can be rotated though as the trigger colliders could well end up pointing upwards so it depends on the flexibility within your game.

Comment
Add comment · Show 7 · 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 adelphiaUK · Jan 03, 2015 at 03:11 PM 0
Share

Hi and thanks for your reply. I downloaded the so called "source" and there is no "source" at all. It's basically a document that contains exactly what you see on the web page, unless I missed something.

avatar image Mmmpies · Jan 03, 2015 at 03:55 PM 0
Share

Ah didn't download it, mainly as I didn't want to hand over my mail, I get enough spam already!

There are already some fluid assets on the store. Depends on your available cash but if it saves you creating your own may well be worth it.

I think there's a free version of fluvio 2 so you can try it out for free.

avatar image adelphiaUK · Jan 03, 2015 at 03:59 PM 0
Share

I know what you mean about spam, but I must admit I haven't had any from them as yet!

I might take a look at Fluvio. I had seen it whilst searching but I thought it was 2D only. Having looked again, they say it's 2D and 3D so I may well give it a shot. I've just had a look at LiquidFun too, but unfortunately, that's 2D only (for now anyway).

avatar image Mmmpies · Jan 03, 2015 at 04:05 PM 0
Share

Hope it helps but there are some other ones there as well (just search liquid or fluid), a shame you're asking now as I think fluvio was on offer a week or two ago.

I guess you could always use the free version for a while as offers tend to crop up every so often.

avatar image adelphiaUK · Jan 03, 2015 at 04:10 PM 0
Share

Yeah, I'm going to give the free version a shot as I'm currently out of work (hence why I'm creating games). I don't think the 100 emitter limitation will impact on what I need to do and I hope it works in Unity Free too (cheap skate I know...).

Show more comments
avatar image
0

Answer by seo_unity · Jan 24, 2018 at 12:30 PM

If you want help, then share your project details at sales@agicent.com. We are a game development company (https://www.agicent.com) and would like to assist you. Cheers :),In case, you are looking for a game development company (https://www.agicent.com), then we can help you. Share your project details at sales@agicent.com and we will assist you for free.

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

28 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

Related Questions

how to make bag filled with water that can be moved by physics? 0 Answers

How do I make a sphere filling animation (optional: with a subtle waving) 0 Answers

Filling array with gameObjects 2 Answers

What is the best way to evenly distribute objects to fill a curved space? 1 Answer

Draw Particles over Text (GUIText or GUI.Label) 3 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