Reputation: 29
Seems like a simple question, but I can't seem to find a solution. I have a 3d cube with two colliders added, a cube collider and a sphere collider. For example, the cube collider is located in the center of the cube and fires when the cube flies through another object. And the sphere is a large collider and it works when the cube flies next to another object. With the OnTriggerEnter method, I can get information about the collider of the object the cube is interacting with. But how to get information about the colliders of the cube itself?
Upvotes: 0
Views: 3670
Reputation: 13
You can use OnCollisonEnter()
to check if your object has hit another collider.
To specify information about each collider on your object, you should be able to use GetType()
to determine which collider was hit.
For example:
private void OnCollisionEnter(Collision collision) {
if (collision.collider.GetType() == typeof(BoxCollider)) {
//Do whatever
}
}
Upvotes: 0