shredz7 — 2016-12-23T11:32:15-05:00 — #1
I'm working on a project in Unity that has a jar model made in blender, and I'm trying to fill one layer with sand, another with rocks, etc. making it customizable by the player. I have some ideas, such as making a GameObject for each layer that has a mesh from blender or somewhere else which perfectly fits, but I cant figure out how to create those. Another idea is to use a particle system, pre-rendered or live.
Thanks for the help!
hiccup — 2017-01-02T17:18:23-05:00 — #2
Hey there @Shredz7!
After doing some research on this, I have found a couple suggestions.
The approach probably depends on how many jars needed, and efficiency considerations.
Perhaps the easiest would be to model a simple rock, and then some sand. Fill the jar with both, and then hide the mesh renderer of a portion of the one you don't want.
If you're doing it over the course of like 100s of jars at once, at that point a particle system may be better, as rendering that many faces could get tricky.
But if it's just a small number of jars, I'd say:
• Model a Rock
• Model / paint a small layer of sand
• Create an array to hold onto the portion of rocks or sand being displayed, and depending on the slider, or player modification, increase or decrease the corresponding one.
Although, it does get more complicated again if you want the sand and rocks to interact with physics. Like the sand pouring between the rocks.
Does this first options sound like something that would be useful for you? Or do you have some more specifications on what you're trying to do with this jar filled with sand and rocks? The ultimate purpose of it helps shape the best method for creating it.
shredz7 — 2017-01-05T19:42:40-05:00 — #3
Thanks a lot @Hiccup !
So, I think I could use two ways to create this effect, but I'll describe them after I talk about my exact situation.
There will be multiple layers of sand or rocks, each with their own individual texture (I'm developing for the iOS so I need to have a bit of a low poly count). Each layer's height is already determined. The only thing that can be changed by the player is the texture which is chosen from a few presets.
My 1st idea for the problem relies on the fact that the player can't change the height of each layer. I could use an external program like Blender (I used that for modeling my jar) to make an object that fills up the entire interior of the jar and then cut it at a certain height, and just texture it while in game. I might be able to make a copy of the glass jar then scale it down to fit it inside then cut it's height to the appropriate level.
My 2nd idea for a similar result is to create a box and texture it with the appropriate one, then use some script to make the mesh only render the object when it is inside the jar, but this idea might not work because of not rendering the textures or maybe not being able to do this at all. I could also use some program or method to clip the mesh???
hiccup — 2017-01-06T12:21:07-05:00 — #4
The first approach you described sounds more feasible for what you're trying to do. Because the layers don't interact with each other, you can just use textures to imitate the glass being filled at various levels. You could even just make specifically sized objects to fill the glasses various height levels, then change the texture of each "level" based on what the user suggests.
shredz7 — 2017-01-06T18:03:58-05:00 — #5
Thanks for giving me the modeling idea, and after that it sparked the technique I thought of. I'm just about to go model my next three layers in Blender and start coding it in.