void OnTriggerEnter2D(Collider2D other) { if (other.tag.Contains(characterTag) && other.transform.name == bodypart) { DrillCharacterController dcc = other.GetComponent <DrillCharacterPart>().DrillController; if (changeHealthAmount > 0) { dcc.Heal(changeHealthAmount); } if (changeHealthAmount < 0) { dcc.Hurt(-changeHealthAmount); } if (addToScoreAmount > 0) { GameManager.Instance.AddToScore(dcc.PlayerNumber, addToScoreAmount); } if (knockBack) { dcc.AddForce( 8f * (other.transform.position - transform.position).normalized / Time.fixedDeltaTime); } if (disableOnEnter) { gameObject.SetActive(false); } } }
// Start is called before the first frame update void Awake() { rb2d = transform.GetComponent <Rigidbody2D>(); rb2d.bodyType = RigidbodyType2D.Kinematic; rb2d.simulated = true; GetComponent <Collider2D>().isTrigger = true; DrillController = transform.parent.parent.GetComponent <DrillCharacterController>(); }