Inaccessible public methods on Collider2D??

I’m trying to access the public method Collider2D.IsTouchingMethod(), but I can’t seem to access this at all from within a script that has a Collider attached. Not just this method, but it seems a lot of these methods are missing.

Is the documentation outdated or?

Are you using the new unity 5? If so have you declared your collider as variable, and gotten the component?

In unity 5 it is necessary to both declare and getcomponent using .GetComponent();

I’ve actually just made a post about it in this forum anticipating the flood of confusion to new users of Unity 5 having released today.

E.G.

GameObject obj; //your game object the scripts attached to
Collider2D col; // the collider on that game object

void Start(){
obj = GetComponent(); //ties the variable to your gameobject
col = obj.GetComponent(); //ties the variable to your collider2D
}

void Update(){

col.functionofyourchoosing()

}

The reason I ask is that from what it sounds like, your unity isn’t seeing what your calling as a Collider2d, meaning it wont have the functions available to it.

Additionally I don’t know much about 2D part of unity, or that function’s use. When in doubt, Youtube may have an example of it being used.

Thanks for the response Castle, I’m on the current build right before 5, so 4.6.2f1. Good point that the documentation might actually be updated from my version, I’ll dig into the release notes and see.

I did try getting the component by type, and also tried just creating a new Collider2D object to see if I had access.

Still no luck.

And there it is

  • Added Physics2D.IsTouching, IsTouchingLayer and Collider2D.IsTouching, IsTouchingLayer methods.

Nice catch! I’d suggest updating to unity 5 now that it has released though, has some very nice additions, unless ofcourse your current project is past a starting point in 4.6.