Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Counting Fluid & Android Export
#2
(15-11-2018, 06:39 PM)Tuna.Y Wrote: Hi All,

I bought this asset a few days ago and everything was going well until I tried to count particles Sonrisa

I know this page: http://obi.virtualmethodstudio.com/tutor...sions.html and spent time there but I couldn't manage to "count" particles. It would be amazing if someone give hand about that.

I have my box collider and script on my Solver object. There is a counter in the script, but it counts as soon as 1 collision happens BETWEEN the fluid particles (not the collider) and it never stops increasing.

Here is my code;

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

[RequireComponent(typeof(ObiSolver))]

public class Fill : MonoBehaviour
{
   ObiSolver solver;
   public int counter = 0;
   public Collider2D targetCollider = null;

   ObiSolver.ObiCollisionEventArgs collisionEvent;

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

   }

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

   void OnDisable()
   {
       solver.OnCollision -= Solver_OnCollision;
   }

   void Solver_OnCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
   {
       foreach (Oni.Contact contact in e.contacts)
       {
           // this one is an actual collision:
           if (contact.distance < 0.01)
           {
               Component collider;
               if (ObiCollider.idToCollider.TryGetValue(contact.other, out collider))
               {
                   counter++;
               }
           }
       }
   }
}


Second thing is, I only see pink screen when I export my game to the Android. I found a similar issue on the forum, did the suggestion (It was something like changing current shader to simple shader) and it didn't work.

Thanks in advance.

Hi,

You're counting how many particles are there in the collider every frame, completely disregarding particle IDs when counting. So if a particle was already inside the collider the previous frame, it will be counted again next frame. That's why the counter will never stop increasing as long as there's any particle inside of it.

There's several solutions for counting particles in the forum, here's one:
http://obi.virtualmethodstudio.com/forum...=collision

As for the pink screen in Android, check what the ADB log says. Your particular device isn't capable of running one or more of the default fluid shaders, so you might have to modify them.
Reply


Messages In This Thread
Counting Fluid & Android Export - by Tuna.Y - 15-11-2018, 06:39 PM
RE: Counting Fluid & Android Export - by josemendez - 15-11-2018, 06:44 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