{
【更新】给小鳄鱼洗澡水实现
https://blog.csdn.net/qq_33967521/article/details/88094639
【更新】用Unity实现两滴水融合(基本实现)篇
https://blog.csdn.net/qq_33967521/article/details/84857972
更简单,效果更好,注意是用shaderlab实现的,可以很容易得到很好的视觉效果,但是我不知道怎么让shader里的水流动起来==
也请有想法的大佬提提意见
}
当在搜索‘如何实现小鳄鱼洗澡’或者‘水融合实现’时,百分百会搜到metaball,然后去外网读了几篇文档,感觉。。。。。。你懂得==
然后决定用贝塞尔曲线+圆球外切线 苟一个先看看效果。。。
目前效果如下:
这里我先用LineRenderer确保一下算法的正确性,目前并没有绘制网格。果然效果有点垃圾
关于外切线
https://www.mathopenref.com/consttangentsext.html
关于贝塞尔曲线
https://blog.csdn.net/eclipsexys/article/details/51956908
主要思路
计算出利用外切线,计算出下面8个点的坐标
通过这8个点,把赛贝尔曲线绘制出来。
反正目前效果不怎么样,这个用来做一些翻页动画还可以。。。
有时间我会在研究研究这个,实在不行还得转回metaball。。。
代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class curve : MonoBehaviour {
private LineRenderer LR;
Vector2[] Mpos = new Vector2[6];
public Transform c1;
public Transform c2;
// Use this for initialization
void Start () {
LR = this.GetComponent<LineRenderer>();
LR.positionCount = 200;
LR.startWidth = 0.06f;
LR.endWidth = 0.06f;
}
private void FixedUpdate()
{
metaball(c1.GetComponent<CircleCollider2D>().radius, c2.GetComponent<CircleCollider2D>().radius, c1.position