I have two colliders, a box2d collider and a circle2d collider on my game object.
I’m trying to send out a Physics2D raycast:
collider2D.enabled = false;
RaycastHit2D hit;
Debug.DrawRay (transform.position, direction*directionDistance, Color.green);
hit = Physics2D.Raycast (transform.position, direction, directionDistance);
collider2D.enabled = true;
When I Debug with the following:
Debug.Log ("collider that's hit");
Debug.Log (hit.collider);
Debug.Log ("this game object");
Debug.Log (this.gameObject.collider2D);
My hit.collider is
UnityEngine.CircleCollider2D
My this.gameObject.collider2D is:
UnityEngine.BoxCollider2D
How do I do a check for my circleCollider?
I just want to make sure the raycast2D.collider is not checking for itself, so I can go ahead and move my object.
I also tried explictly casting for a circle:
Debug.Log ("hit------");
Debug.Log (hit.collider);
Debug.Log (this.gameObject.collider2D as CircleCollider2D);
Debug.Log ("endhit------");
However for this.gameObject.collider2D as CircleCollider2D I then get null.