# Declaring collider types

**URL:** https://discussions.unity.com/t/declaring-collider-types/603834
**Category:** Physics
**Tags:** Scripting
**Created:** [November 2, 2015, 3:27pm UTC](https://discussions.unity.com/t/declaring-collider-types/603834 "2015-11-02T15:27:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kittik](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/kittik/32/491386_2.png) [@kittik](https://discussions.unity.com/u/kittik)
#### Post date: [November 2, 2015, 3:27pm UTC](https://discussions.unity.com/t/declaring-collider-types/603834/1 "2015-11-02T15:27:12Z")

</div>

I am using two similar functions on a character that distinguishes between a box collider and a sphere collider. I though by using -

```csharp
void OnTriggerEnter(SphereCollider other)
    {
//Do stuff
}

void OnTriggerEnter(BoxCollider other)
    {
//Do different stuff
}

```

I would be able to call different actions, however I am getting the error -  
_Script error: OnTriggerEnter_  
_This message parameter has to be of the type: Collider_

I know that using the word Collider, would call the function. However that calls any type of Collider, not a specific collider, which is what I am trying to do. MonoDevelop didn’t have any problem with me typing SphereCollider and BoxCollider, even having it in the auto complete suggestions.

Maybe I am missing something under _using Unity… using System…_ Could someone please advise me on how to look for Trigger colliders separately, i.e. one way for Boxes and another for Spheres?

---

<div class="post-metadata">

### Author: ![StarManta](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/starmanta/32/280327_2.png) [@StarManta](https://discussions.unity.com/u/StarManta)
#### Post date: [November 2, 2015, 3:29pm UTC](https://discussions.unity.com/t/declaring-collider-types/603834/2 "2015-11-02T15:29:01Z")

</div>

```auto
void OnTriggerEnter(Collider other) {
if (other is BoxCollider) {
BoxCollider otherAsBox = other as BoxCollider;
}
else if (other is SphereCollider) {
}
}

```

---

<div class="post-metadata">

### Author: ![kittik](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/kittik/32/491386_2.png) [@kittik](https://discussions.unity.com/u/kittik)
#### Post date: [November 2, 2015, 3:58pm UTC](https://discussions.unity.com/t/declaring-collider-types/603834/3 "2015-11-02T15:58:25Z")

</div>

Thank you, it works as intended. Much appreciated.
