private void Update()
 {
     if (Input.GetMouseButton(0))
     {
         Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f);
         Vector3 viewPos  = _camera.ScreenToViewportPoint(mousePos);
         if (viewPos.x > 0 && viewPos.x < 1 && viewPos.y > 0 && viewPos.y < 1)
         {
             Vector3 wordPos = _camera.ScreenToWorldPoint(mousePos);
             for (int i = 0; i < count; i++)
             {
                 Vector3 position = wordPos + UnityEngine.Random.insideUnitSphere * radius;
                 position.z = 0f;
                 fluidSystem.EmitWater(position, Vector2.zero);
             }
         }
     }
     if (Input.GetMouseButton(1))
     {
         Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f);
         Vector3 viewPos  = _camera.ScreenToViewportPoint(mousePos);
         if (viewPos.x > 0 && viewPos.x < 1 && viewPos.y > 0 && viewPos.y < 1)
         {
             Vector3 wordPos = _camera.ScreenToWorldPoint(mousePos);
             for (int i = 0; i < count; i++)
             {
                 Vector3 position = wordPos + UnityEngine.Random.insideUnitSphere * radius;
                 position.z = 0f;
                 fluidSystem.EmitSteam(position, Vector2.zero);
             }
         }
     }
     if (Input.GetMouseButtonDown(2))
     {
         Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f);
         Vector3 viewPos  = _camera.ScreenToViewportPoint(mousePos);
         if (viewPos.x > 0 && viewPos.x < 1 && viewPos.y > 0 && viewPos.y < 1)
         {
             Vector3 wordPos = _camera.ScreenToWorldPoint(mousePos);
             fluidSystem.EmitExplosion(wordPos, explosionForce, explosionLifeTime);
         }
     }
 }
Beispiel #2
0
 public void doExplosion(Vector3 position, float force, float radius)
 {
     StartCoroutine(waitAndExplode(position, force, radius));
     fluidSystem.EmitExplosion(position, force / 100f, 0.2f);
 }