Obi Official Forum
Collision code sample not working - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Collision code sample not working (/thread-782.html)



Collision code sample not working - aphixe - 08-12-2018

I copied the script example to do collision test. and unity says it can't convert out from the collider

Assets/Scripts/GrabRope.cs(33,64): error CS1503: Argument `#2' cannot convert `out UnityEngine.Collider' expression to type `out UnityEngine.Component'


 Collider collider;
if (ObiCollider.idToCollider.TryGetValue(contact.other,out collider)){
// do something with the collider.
}


i looked at CollisionEventHandler and it uses Component collider;  is that what it should be? 

all i know is its not working. trying for a long time today to code a grab the rope script


RE: Collision code sample not working - josemendez - 09-12-2018

(08-12-2018, 06:38 AM)aphixe Wrote: I copied the script example to do collision test. and unity says it can't convert out from the collider

Assets/Scripts/GrabRope.cs(33,64): error CS1503: Argument `#2' cannot convert `out UnityEngine.Collider' expression to type `out UnityEngine.Component'


 Collider collider;
if (ObiCollider.idToCollider.TryGetValue(contact.other,out collider)){
// do something with the collider.
}


i looked at CollisionEventHandler and it uses Component collider;  is that what it should be? 

all i know is its not working. trying for a long time today to code a grab the rope script

For 3.3 and up the "collider" variable should be of type Component, as the idToCollider dictionary stores components, not colliders. We will correct the documentation asap. Thanks for pointing this out!