I want to create realistic pizza and allow user interact with it.
What I want:
What I created:
I created model of the pizza (8 pieces) in Blender, then imported it into Unity. The piece of pizza looks very artificial, mostly because it is "rigid triangle".
How can I make the cheese stretch and break when the user moves a piece?
Answer
The Simple Way
Add a quad which connects adjacent slices to each other. Texture this with a nice, melted cheese texture, complete with holes. As the slice is moved away the quad will naturally be stretched and thus stretch and skew the texture.
This should look reasonable, although there will be no break. What to do here is make that texture an animated one. Iterate through the animation based on the quads area (or just the distance between the slices) instead of time. As it gets pulled further away more holes will appear due to the animation progressing.
Eventually when a distance threshold is hit, split the quad into two, programatically shrink the two quads in the direction of their attached slices to shrink them a bit and keep the animation playing which shows the snapping. Freeze the animation at the end.
For a bit more dynamics, you could attach the quad to the two slices using a joint in a physics engine.
The Hard Way
Use a soft-body physics engine or write one. Define a cloth section between the slices and texture it with cheese. Allow the physics engine to model the dynamics of the material stretching and snapping.
This is a far more intensive, but more generally applicable method. It may also be very uncontrollable but could be an overall more compelling effect.
No comments:
Post a Comment