【Unity】流体模拟(更新ing)

Fluid Simulation

参考于 Sebastian Lague 的项目进行分析学习
流体模拟视频链接


文章目录

  • Fluid Simulation
  • 2D流体
    • Simulation2D.cs


2D流体

Simulation2D.cs

  • 流体的边界用OnDrawGizmos设置流体的边界
    void OnDrawGizmos()
    {
        Gizmos.color = new Color(0, 1, 0, 0.4f);
        Gizmos.DrawWireCube(Vector2.zero, boundsSize);
        Gizmos.DrawWireCube(obstacleCentre, obstacleSize);

        if (Application.isPlaying)
        {
            Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            bool isPullInteraction = Input.GetMouseButton(0);
            bool isPushInteraction = Input.GetMouseButton(1);
            bool isInteracting = isPullInteraction || isPushInteraction;
            if (isInteracting)
            {
                Gizmos.color = isPullInteraction ? Color.green : Color.red;
                Gizmos.DrawWireSphere(mousePos, interactionRadius);
            }
        }

    }

你可能感兴趣的:(Unity3D开发日常,unity,游戏引擎,图形渲染,c#)