unity中的聊天气泡_小气泡:Unity中的自定义肥皂泡沫物理

unity中的聊天气泡

Veteran indie developer Stu Denman had a grandfather who had worked on the Manhattan Project, and afterward studied the physics of soap bubbles. Half a century later, Stu couldn’t get his grandfather’s bubble work out of his head. This is a story of how he developed custom physics in Unity to make a mesmerizing 2D game called Tiny Bubbles.

经验丰富的独立开发者Stu Denman的祖父曾从事“曼哈顿计划”的工作,后来研究了肥皂泡的物理原理。 半个世纪后,斯图无法摆脱祖父的泡沫。 这是关于他如何在Unity中开发自定义物理学以制作令人着迷的2D游戏Tiny Bubbles的故事。

When Denman was considering new game ideas, he wanted to create something like the classic, Tetris: a game with no story, no art team, and no main characters, yet one that would stand out because of its powerful game mechanics.

当丹曼(Denman)考虑新的游戏创意时,他想创造类似经典的《 俄罗斯方块》 :一款没有故事,没有美术团队,没有主要角色的游戏,但由于其强大的游戏机制而脱颖而出。

His mind kept wandering back to his grandfather, a scientist who had studied the properties of plutonium and discovered similarities between molten metals and the unusual behavior of soap bubble foams.

他的思想一直在回溯到他的祖父。祖父曾研究studied的性质,并发现熔融金属与肥皂泡泡沫的异常行为之间存在相似之处。

“Soap bubbles have these weird properties where the edges meet at vertices. 2D soap foams connect on three surfaces, never four or two, and always at a 120-angle. I became determined to create a game using the physics of soap bubbles: how they connect, the surface tension and the pressure,” Denman says.

肥皂泡具有这些怪异的特性,边缘在顶点相交。 2D肥皂泡沫连接在三个表面上,从不连接四个或两个,并且始终以120度角连接。 我决心使用肥皂泡的物理原理来创建游戏:它们如何连接,表面张力和压力。” Denman说。

真正复杂的数学和肥皂原型 (Really complicated math and soapy prototypes)

In the first instance, Denman attempted to make a prototype based on mathematical theory.

首先,登曼(Denman)尝试基于数学理论制造原型。

“I had to teach myself this horrendous math,” he says. “I read a PhD thesis on non-linear Jacobian Matrix solvers and attempted to use it to reproduce the physics. But in the end, it didn’t behave correctly in all cases. I had to throw it out because it worked 99% of time, but for games you need it to work 100 percent of time.”

他说:“我必须自学这种可怕的数学。” “我读了关于非线性雅可比矩阵求解器的博士学位论文,并试图用它来重现物理学。 但最后,它在所有情况下均无法正常运行。 我不得不把它扔掉,因为它可以工作99%的时间,但对于游戏,您需要它工作100%的时间。”

Denman was almost ready to give up when he realized that, instead of using mathematical theory, he could simulate what molecules do in nature on a scale that would work for games. So he studied the surface tension and molecular dynamics, for example, how one side is attracted to fat, one side to water. And he began a series of prototypes where he converted circles into soap foams.

丹曼意识到自己可以使用分子模拟自然界中发生的事情,而不是使用数学理论,几乎准备放弃。 因此,他研究了表面张力和分子动力学,例如,一方面吸引脂肪,另一方面吸引水。 然后,他开始了一系列原型,将圆转变成肥皂泡沫。

演示地址

脚本中的复杂分子动力学 (Complex molecular dynamics in script)

In order to get where he wanted to go, Denman had to write a custom physics engine in C# built from script via Unity’s powerful IL2CPP compiler. Because his molecular dynamics engine has to process force calculations for tens of thousands of molecules, it had to be carefully tuned to run as fast as possible, even on older mobile devices. Before the bubbles can be displayed, the molecules are “skinned” with dynamic meshes and the interior areas are triangulated. All this complex processing is achieved purely in C# script.

为了到达他想去的地方,Denman必须通过Unity强大的IL2CPP编译器从C#编写一个自定义物理引擎。 由于他的分子动力学引擎必须处理成千上万个分子的力计算,因此即使在较旧的移动设备上,也必须对其进行仔细的调整以使其尽可能快地运行。 在显示气泡之前,将分子用动态网格“蒙皮”,并对内部区域进行三角剖分。 所有这些复杂的处理过程完全是用C#脚本实现的。

Denman was able to use tools like Apple’s Instruments to profile the C code generated by IL2CPP, running on the target iPhone. Based on these results, he was able to modify the C# scripts, so that the inner-loops of the dynamics engine would run at native speeds, even though it was authored in script.

Denman能够使用Apple Instruments等工具来分析目标iPhone上运行的IL2CPP生成的C代码。 基于这些结果,他能够修改C#脚本,以便动态引擎的内部循环将以本机速度运行,即使它是用脚本编写的。

After three days, he had made a solution that achieved realistic-looking animations, running at 60 FPS on mobile devices and was stable enough that the simulation never collapsed or exploded out to infinity. Denman, achieving the cool rubber-band effect he had observed in nature, where waves and undulations run through the bubbles.

三天后,他制定了一个解决方案,该方案实现了逼真的动画,在移动设备上以60 FPS的速度运行,并且足够稳定,因此模拟不会崩溃或爆炸到无限远。 丹曼(Denman)实现了他在自然界观察到的凉爽的橡皮筋效果,波浪和起伏穿过气泡。

玩泡泡有回报 (Playing with bubbles pays off)

Once he had his custom physics and the bubble editor, Denman could play around with the mechanics.

一旦有了自定义物理和气泡编辑器,Denman就可以尝试使用这些力学。

“Really what your doing is exploring your restrictions, the rules you’re going to give players, what I call the possibility space of what things you can create,” he says.”I tried out different bubble puzzles, threw out what didn’t work and kept what was fun. In short, Unity allowed me to play, and that’s what I love to do when I design games.”

他说:“实际上,您正在做的事情是探索自己的限制,要赋予玩家的规则,我可以创造的东西可能性空间 。”我尝试了各种泡泡拼图,扔掉了没有的东西。工作,并保持有趣的地方。 简而言之,Unity允许我玩游戏,这就是我在设计游戏时喜欢做的事情。”

So far, Denman’s playful experimentations have resulted in multiple awards, including SXSW Gamer’s Voice: Best Mobile Game, Google Indie Festival, Intel Buzz: Best Overall PC Game, Seattle Indie Games Competition, and Mobile Games Forum Indie Showdown and Best Quickplay at IMGA Global, First Runner-Up at Big Indie Pitch at GDC and Grand Prize at The Label’s Indie Showdown.

到目前为止,Denman的顽皮实验已经获得了多个奖项,包括SXSW Gamer的Voice:最佳手机游戏,Google Indie Festival,Intel Buzz:最佳整体PC游戏,Seattle Indie Games Competition,以及IMGA Global的Mobile Games Forum Indie Showdown和Best Quickplay。 ,在GDC的Big Indie Pitch上获得亚军,在The Label的Indie Showdown获得大奖。

You can learn more about how Denman created his game in the Unity for 2D Tiny Bubbles case study.

您可以在Unity for 2D Tiny Bubbles案例研究中了解有关Denman如何创建他的游戏的更多信息

翻译自: https://blogs.unity3d.com/2018/04/02/tiny-bubbles-custom-soap-foam-physics-in-unity/

unity中的聊天气泡