Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Counting Fluid & Android Export
#8
(15-11-2018, 09:40 PM)josemendez Wrote: Works for me. Make sure you're indexing the correct collider map in the for loop, ie ObiCollider2D instead of ObiCollider. I'm pasting the 2D version just in case:

Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;

[RequireComponent(typeof(ObiSolver))]
public class CollisionCounter : MonoBehaviour {

   ObiSolver solver;
   public int counter = 0;
   public Collider2D targetCollider = null;
   
   Obi.ObiSolver.ObiCollisionEventArgs frame;
   HashSet<int> particles = new HashSet<int>();

   void Awake(){
       solver = GetComponent<Obi.ObiSolver>();
   }

   void OnEnable () {
       solver.OnCollision += Solver_OnCollision;
   }

   void OnDisable(){
       solver.OnCollision -= Solver_OnCollision;
   }
   
   void Solver_OnCollision (object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
   {
       HashSet<int> currentParticles = new HashSet<int>();
       
       for(int i = 0;  i < e.contacts.Count; ++i)
       {
           if (e.contacts.Data[i].distance < 0.001f)
           {

               Component collider;
               if (ObiCollider2D.idToCollider.TryGetValue(e.contacts.Data[i].other,out collider)){

                   if (collider == targetCollider)
                       currentParticles.Add(e.contacts.Data[i].particle);

               }
           }
       }

       particles.ExceptWith(currentParticles);
       counter += particles.Count;
        particles = currentParticles;Debug.Log(counter);
   }

}

Hi Jose,

I have checked the ADB logs. This is the error that I'm getting when I open the scene.

CommandBuffer: temporary render texture _FluidDepthTexture not found while executing Render fluid (SetGlobalTexture)

Tried with 2 different shaders. Obi/ParticleShader and Obi/FluidColorsOpaque

Thanks
Reply


Messages In This Thread
Counting Fluid & Android Export - by Tuna.Y - 15-11-2018, 06:39 PM
RE: Counting Fluid & Android Export - by Tuna.Y - 15-11-2018, 08:12 PM
RE: Counting Fluid & Android Export - by Tuna.Y - 15-11-2018, 08:43 PM
RE: Counting Fluid & Android Export - by Tuna.Y - 16-11-2018, 06:24 AM
RE: Counting Fluid & Android Export - by Tuna.Y - 16-11-2018, 09:15 AM
RE: Counting Fluid & Android Export - by Tuna.Y - 16-11-2018, 12:57 PM
RE: Counting Fluid & Android Export - by Tuna.Y - 16-11-2018, 01:58 PM