(27-11-2020, 04:04 PM)josemendez Wrote: hmm.. I get the impression that you don't understand the code at all
This line makes no sense whatsoever. You're comparing objects of different types (which won't ever be equal to each other). "emitter" is of type ObiEmitter, and "player" is of type ObiCollider2D. A emitter is not a collider, so this will always be false.
Moreover, you've declared the emitter variable twice: once as a public member of the script, and another within the Solver_OnCollision method. This script won't compile.
At this point I should really insist that you invest some time learning basic programming, as I can't possibly handhold you trough every line of code you write. Not that I have anything against helping you, it's just that I don't have the resources to do that. This forum is for help with Obi-related issues only.
I have the attention span of monkey and the awareness of a toddler...
Sorry for the stupid questions i asked during the thread, and yea, i have a lot to learn about programing. I think i managed to make it work tho:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Obi;
[RequireComponent(typeof(ObiSolver))]
public class Collision2 : MonoBehaviour
{
ObiSolver solver;
public ObiCollider2D player;
public ObiEmitter fluid;
Obi.ObiSolver.ObiCollisionEventArgs collisionEvent;
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)
{
ObiSolver.ParticleInActor pa = solver.particleToActor[contact.particle];
ObiEmitter emitter = pa.actor as ObiEmitter;
if (pa.actor == fluid)
{
ObiColliderBase collider = world.colliderHandles[contact.other].owner;
if (collider == player)
GameObject.Destroy(collider.gameObject);
}
}
}
}
}
The player dies when touching the "fluid" emitter. Posted it just for others to see so it might help them... With this i solved my main problems with obi for my proyect, dont know if ill post any question again, but for the time being ill let you rest Jose
(its been a long fkn thread) Thanks for all the help and the patience, i wish all forums where like this one...
Cheers.