Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Obi fluid collision
#1
I have a container with liquid which I move, I want it to do something when it spills and collides with the floor, I am using an event to check when it collides with the floor, but the performance when using this script drops from 50 fps to 17fps what I could do ?

Code:
    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)
    {
        var world = ObiColliderWorld.GetInstance();
        foreach (Oni.Contact contact in e.contacts)
        {
            // this one is an actual collision:
            if (contact.distance < 0.01)
            {
                ObiColliderBase collider = world.colliderHandles[contact.other].owner;
                if (collider.name!="Piso")
                {
                    Debug.Log(collider.name);
                    solver.OnCollision -= Solver_OnCollision;
                    // do something with the collider.
                }
            }
        }
    }
Reply


Messages In This Thread
Obi fluid collision - by JskT01 - 06-03-2021, 02:51 AM
RE: Obi fluid collision - by josemendez - 06-03-2021, 09:41 AM
RE: Obi fluid collision - by JskT01 - 06-03-2021, 09:51 PM
RE: Obi fluid collision - by josemendez - 08-03-2021, 08:24 AM
RE: Obi fluid collision - by JskT01 - 08-03-2021, 07:05 PM
RE: Obi fluid collision - by josemendez - 09-03-2021, 11:27 AM
RE: Obi fluid collision - by JskT01 - 09-03-2021, 09:53 PM
RE: Obi fluid collision - by josemendez - 10-03-2021, 09:05 AM
RE: Obi fluid collision - by JskT01 - 10-03-2021, 07:55 PM
RE: Obi fluid collision - by josemendez - 11-03-2021, 09:02 AM