Hello,
I have a very strange problem. I have a script to manage all the collisions of the character, so its only function is OnCollisionEnter. It works fine but when I’m trying to disable it, using
Player2.GetComponent(Collisions2).enabled = false;
Player1.GetComponent(Player_Sidescroll).enabled = false;
It appears as if it disables (the checkbox in the inspector unchecks itself). but it still works! The other script disabled works fine… Weirder still, even if I disable the code in the inspector it still works. Only if I delete it, then it stops working. Again, the only function on the collision code is
function OnCollisionEnter(hit : Collision)
{
if(hit.gameObject.tag == "fireball")
{
Destroy(hit.gameObject);
//Generate Explosion
var explosion = Instantiate(ExplosionPrefab,transform.position, transform.rotation);
Health2.damage += 103; // do damage
playerSprite.DoAnim("Hurt"); // animate
}
}
I have no idea why it does this. Any ideas?