![]() |
Help I want to create an event when clothes touch a particular object. - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html) +--- Thread: Help I want to create an event when clothes touch a particular object. (/thread-2711.html) |
I want to create an event when clothes touch a particular object. - k2xh0115 - 21-01-2021 I tried using http://obi.virtualmethodstudio.com/tutorials/scriptingcollisions.html, but I wanted to find an easier way. So, I'm trying to contact using obicontacteventdispatcher. (Enter/Stay/Exit) works satisfactorily and satisfactorily. But what I want is to operate it when a particular collider touches it. For example, typically in Unity, private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "testModel") { //func(); } } In this way, only objects named "testModel" can be contacted, but I tried many things using obicontacteventdispatcher, but I couldn't. Could you tell me how to contact only certain objects? Thank you for your quick response. RE: I want to create an event when clothes touch a particular object. - josemendez - 21-01-2021 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/tutorials/scriptingcollisions.html Quote:ObiColliderBase collider = ObiColliderWorld.GetInstance().colliderHandles[contact.other].owner; Putting it all together: Code: using UnityEngine; 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. RE: I want to create an event when clothes touch a particular object. - k2xh0115 - 21-01-2021 (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: Wow... it's applied so perfectly well. Thank you very much! |