04-07-2022, 02:12 PM
(04-07-2022, 01:23 PM)josemendez Wrote: Hi,
Contacts do not have “particle” or “other” member variables.
You must use contact.bodyA to access the simplex, and contact.bodyB to access the collider. See the scripting section of the manual for details:
http://obi.virtualmethodstudio.com/manua...sions.html
yes I am using bodyA and bodyB but it always gives the wrong ropes ( I mean wrong names of colliding ropes )
this is the script :
Code:
using System.Collections;
using System.Collections.Generic;
using Obi;
using UnityEngine;
public class RopeCollision : MonoBehaviour
{
private ObiSolver _solver;
private ObiSolver.ObiCollisionEventArgs _collisionEvent;
private void Awake()
{
_solver = GetComponent<ObiSolver>();
}
private void OnEnable()
{
_solver.OnParticleCollision += Solver_OnParticleCollision;
}
private void OnDisable()
{
_solver.OnParticleCollision -= Solver_OnParticleCollision;
}
private void Solver_OnParticleCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
{
var world = ObiColliderWorld.GetInstance();
foreach (var contact in e.contacts)
{
// this one is an actual collision:
//Debug.Log(contact.pointA + " pt");
if (true || contact.distance < 0.01f)
{
var pa = _solver.particleToActor[contact.bodyA];
var po = _solver.particleToActor[contact.bodyB];
if (pa.actor.gameObject != po.actor.gameObject)
{
Debug.Log(pa.actor.gameObject.name + " collides with: " + po.actor.gameObject.name);
}
}
}
}
}