When i make a prefab and add this script:
#pragma strict
public var damage: float = 5;
public var stuckArrowPosition: Vector3;
public var stuckArrowRotation: Quaternion;
public var hit: boolean = false;
public var rb = GetComponent.<Rigidbody2D>();
public var tagNotToKill: String;
function OnCollisionEnter2D ( col: Collision2D ) {
if (col.gameObject != null && hit == false && col.gameObject.tag != tagNotToKill) {
Debug.Log(col);
col.gameObject.SendMessage("ApplyDamage", damage);
}
else
{
transform.parent = col.transform;
rb.isKinematic = true;
rb.fixedAngle = true;
hit = true;
Destroy(this.gameObject, 15);
}
}
Unity crashes as soon as I add it. If i add it to a game object which isn’t a prefab, it doesn’t crash and if I use a different script it doesn’t crash, even on a prefab. I’ve tried creating the script from the menu inside the prefab, and dragging in one i made before, and none of them work.