Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  please help
#5
Code:
using UnityEngine;
using Obi;

[RequireComponent(typeof(ObiSolver))]
public class CollisionEventHandler : MonoBehaviour {

    ObiSolver solver;
        GameObject collision;

    void Awake(){
        solver = GetComponent&ltObiSolver>();
    }

    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();

        // just iterate over all contacts in the current frame:
        foreach (Oni.Contact contact in e.contacts)
        {
            // if this one is an actual collision:
            if (contact.distance < 0.01)
            {
                ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;
                if (col != null)
                {
                                        collision=gameObject.Find(col.name);
                    // do something with the collider.
                }
            }
        }
    }

}

here collision object takes only one value but I want to get all the objects that hit the object.
Reply


Messages In This Thread
please help - by Alikemalerdem - 25-03-2022, 07:57 PM
RE: please help - by josemendez - 26-03-2022, 12:03 AM
RE: please help - by Alikemalerdem - 26-03-2022, 08:17 AM
RE: please help - by josemendez - 26-03-2022, 12:08 PM
RE: please help - by Alikemalerdem - 26-03-2022, 03:22 PM
RE: please help - by josemendez - 26-03-2022, 07:05 PM
RE: please help - by Alikemalerdem - 27-03-2022, 04:12 PM