Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  I want to create an event when clothes touch a particular object.
#3
(21-01-2021, 09:09 AM)josemendez Wrote: In Obi this is done exactly the same way, once you have a reference to the collider involved in the collision, you just check its name (or layer, tag, etc). You can get a reference to the collider from a contact as explained in the manual:

http://obi.virtualmethodstudio.com/tutor...sions.html

Putting it all together:

Code:
using UnityEngine;
using Obi;

public class ContactWithNamedObject : MonoBehaviour
{

    public void OnContactEnterProcess(ObiSolver solver, Oni.Contact contact)
    {
        ObiColliderBase other = ObiColliderWorld.GetInstance().colliderHandles[contact.other].owner;
        if (other.gameObject.name == "testModel")
        {
            Debug.Log("Collision!");
        }
    }
}

Then you just have to subscribe the OnContactEnterProcess function to the OnContactEnter event of the dispatcher. You can do this trough the inspector, or programmatically.

Wow... it's applied so perfectly well. Thank you very much!
Reply


Messages In This Thread
RE: I want to create an event when clothes touch a particular object. - by k2xh0115 - 21-01-2021, 10:02 AM