Obi Official Forum
Help Add vector and script when hit collider. - 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 Add vector and script when hit collider. (/thread-976.html)



Add vector and script when hit collider. - Richard - 13-03-2019

Can I add vector and script to obi tearable cloth when it hit somthing collider(box, sphere or mesh)?


RE: Add vector and script when hit collider. - josemendez - 13-03-2019

(13-03-2019, 09:54 AM)Richard Wrote: Can I add vector and script to obi tearable cloth when it hit somthing collider(box, sphere or mesh)?

Yes, use collision callbacks:
http://obi.virtualmethodstudio.com/tutorials/scriptingcollisions.html


RE: Add vector and script when hit collider. - Richard - 14-03-2019

The page is written about setting of obi cloth, but do I not have to set up collider the cloth would collide with? Just add obi collider?


RE: Add vector and script when hit collider. - josemendez - 14-03-2019

(14-03-2019, 11:29 AM)Richard Wrote: The page is written about setting of obi cloth, but do I not have to set up collider the cloth would collide with? Just add obi collider?

Not sure I understand your question. Adding a ObiCollider component to any existing collider allows it to interact with Obi actors. That's it, you don't need any additional set up. See: http://obi.virtualmethodstudio.com/tutorials/collisions.html

Then, if you need to detect which solver particles have collided with a collider, you subscribe to the solver's OnCollision event (as described i the link I provided).


RE: Add vector and script when hit collider. - Richard - 14-03-2019

(14-03-2019, 12:52 PM)josemendez Wrote: Not sure I understand your question. Adding a ObiCollider component to any existing collider allows it to interact with Obi actors. That's it, you don't need any additional set up. See: http://obi.virtualmethodstudio.com/tutorials/collisions.html

Then, if you need to detect which solver particles have collided with a collider, you subscribe to the solver's OnCollision event (as described i the link I provided).

I could do that.

Can I attach script or component without colliding? For example, particles that are in (or enter) the box(or in the area) gain script or component.


RE: Add vector and script when hit collider. - josemendez - 14-03-2019

(14-03-2019, 04:10 PM)Richard Wrote: I could do that.

Can I attach script or component without colliding? For example, particles that are in (or enter) the box(or in the area) gain script or component.

Hi,

I think you want to use a trigger (built-in Unity stuff). Simply enable the "IsTrigger" checkbox of your collider. It will detect particles entering it, but won't generate collisions. See:
https://docs.unity3d.com/Manual/CollidersOverview.html


RE: Add vector and script when hit collider. - Richard - 15-03-2019

(14-03-2019, 05:49 PM)josemendez Wrote: Hi,

I think you want to use a trigger (built-in Unity stuff). Simply enable the "IsTrigger" checkbox of your collider. It will detect particles entering it, but won't generate collisions. See:
https://docs.unity3d.com/Manual/CollidersOverview.html

Hello.

How can I fix:
NullReferenceException: Object reference not set to an instance of an object
Obi.ObiCloth.AddToSolver (System.Object info) (at Assets/Obi/Scripts/Actors/ObiCloth.cs:167)
Obi.ObiActor.Start () (at Assets/Obi/Scripts/Actors/ObiActor.cs:163)
?


RE: Add vector and script when hit collider. - josemendez - 15-03-2019

(15-03-2019, 11:48 AM)Richard Wrote: Hello.

How can I fix:
NullReferenceException: Object reference not set to an instance of an object
Obi.ObiCloth.AddToSolver (System.Object info) (at Assets/Obi/Scripts/Actors/ObiCloth.cs:167)
Obi.ObiActor.Start () (at Assets/Obi/Scripts/Actors/ObiActor.cs:163)
?

Hi,

This should only happen if you set the solver to null programmatically, then call AddToSolver(). Can you describe what you're doing?


RE: Add vector and script when hit collider. - Richard - 16-03-2019

(15-03-2019, 04:42 PM)josemendez Wrote: Hi,

This should only happen if you set the solver to null programmatically, then call AddToSolver(). Can you describe what you're doing?
I am trying to put pants on human. I would like to fasten pants like rubber of clothing. However, it is hard to pick up particle on script. I use trigger.