15-11-2018, 06:39 PM
Hi All,
I bought this asset a few days ago and everything was going well until I tried to count particles
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;
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.
I bought this asset a few days ago and everything was going well until I tried to count particles
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.