11-05-2021, 01:33 AM
(This post was last modified: 11-05-2021, 02:05 AM by boulder.
Edit Reason: Change topic prefix to help
)
Hi,
I have some problems with collisions. I am using the code below for each collision to get the touching each other rope but it gives wrong/inconsistent data.
Here each rope touching each other should be having darker tone. I tried different settings and it did not change. Ropes are in the same z-axis and they definitely touch as I checked from different angles. Surface collision is open, all works as expected, I am using the latest 6.0.1 version.
Here is a video : Video
Do anyone having the same issue who can help me?
Thanks!
I have some problems with collisions. I am using the code below for each collision to get the touching each other rope but it gives wrong/inconsistent data.
Here each rope touching each other should be having darker tone. I tried different settings and it did not change. Ropes are in the same z-axis and they definitely touch as I checked from different angles. Surface collision is open, all works as expected, I am using the latest 6.0.1 version.
Here is a video : Video
Do anyone having the same issue who can help me?
Thanks!
Code:
using UnityEngine;
using Obi;
public class RopeCollision : MonoBehaviour
{
ObiSolver solver;
void Start()
{
solver = GetComponent<ObiSolver>();
solver.OnParticleCollision += Solver_OnCollision;
}
void OnDisable()
{
solver.OnParticleCollision -= Solver_OnCollision;
}
void Solver_OnCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
{
var world = ObiColliderWorld.GetInstance();
foreach (Oni.Contact contact in e.contacts)
{
var pa = solver.particleToActor[contact.bodyA];
var po = solver.particleToActor[contact.bodyB];
if (pa == null || po == null)
return;
if (pa.actor.gameObject.name != po.actor.gameObject.name)
{
//print(pa.actor.gameObject+" , "+ po.actor.gameObject);
GameManager.Instance.Colliding(pa.actor.gameObject, po.actor.gameObject);
}
}
}
}