27-11-2020, 03:31 PM
(This post was last modified: 27-11-2020, 03:33 PM by JoseCarlos S.)
(27-11-2020, 03:16 PM)josemendez Wrote: You're not checking if the collider reported by the contact is the player, you're merely checking if the player exists. Since this is probably always true, any collider relatively close to the fluid will be destroyed.
Correct solution:
Code: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 == player)
GameObject.Destroy(collider.gameObject);
}
}
}
Nice! It works! If i change the script to be for the emitter instead of the solver, can i get this interaction with one fluid but not the other? Right now it dies when touching any fluid, and i whant it killing itself when touching certain fluids/emitters