- Home /
How can I disable this collider, when two are present on the gameobject
I have a door game object. It has a box collider to make the player unable to pass through the door, and a sphere collider to sense the players presence and open the door. It has this script
using UnityEngine;
using System.Collections;
public class DoorOpen : MonoBehaviour
{
private GameObject player;
void Awake()
{
player = GameObject.FindGameObjectWithTag("Player");
}
void OnTriggerEnter (Collider other)
{
if(other.gameObject == player)
{
transform.Rotate(0,90,0);
}
}
}
I have found the possible solution of collider.enable = false;
but i think this will create a problem since I have two colliders. If it helps, the sphere collider is marked as trigger, and the box collider is not. My question, how do I deactivate the sphere collider, without messing with the box collider?
Answer by Deign · May 11, 2014 at 04:01 AM
Use a public variable to hold the collider you want to disable and simply reference it by dragging the collider you want to be controlled by the script onto the field in the inspector.
Your answer
Follow this Question
Related Questions
Trigger not working 2D 1 Answer
Weird behaviour with OnTriggerEnter 0 Answers
Ideas for detecting collision speed with trigger? 2 Answers
Problems with the Trigger Collider (randomly fictional) 1 Answer
Trigger collider information 3 Answers