I was under the impression that if a component is attached to an object, but disabled, then no functions inside should be running.
However, OnCollisionEnter will run even if the component is disabled.
Is this intended or is this a bug?
I was under the impression that if a component is attached to an object, but disabled, then no functions inside should be running.
However, OnCollisionEnter will run even if the component is disabled.
Is this intended or is this a bug?
I dont know how to answer you… Maybe is the Character Controller attached to the gameObject…
Have you actually tested it to see that it truly turns off on your end, or are you just assuming?
Here are the repro steps I use to get it:
Result:
The console will display the debug log sent by the disabled component.
Expected:
No debug message to appear, since no functions in the script should be running.
Repro Rate:
15/15
The code:
using UnityEngine;
using System.Collections;
public class TriggerTest : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
}
public void OnCollisionEnter(Collision collision)
{
Debug.Log(gameObject.name + " has collided with " + collision.gameObject.name);
}
}
There is no bug, it is specifically written in the documentation
,
The checkbox for disabling a MonoBehavior (on the editor) will only prevent Start(), Awake(), Update(), FixedUpdate(), and OnGUI() from executing. If none of these functions are present, the checkbox is not displayed.
so if you just remove the empty Start and Update function you will find that there is no checkbox in the inspector.
I was assuming that, because just know i understood your question… But its already answered.