private void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.CompareTag("Player")) { Character_Behaviour playerBehaviour = col.gameObject.GetComponentInParent <Character_Behaviour>(); float differenceX = col.bounds.center.x - GetComponent <Collider2D>().bounds.center.x; playerBehaviour.TakeDamage(damage, differenceX, "Ranged", playerAnimData); } }
private void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.CompareTag("Character_Reflect") && col.GetComponentInParent <Character_Behaviour>().withKnife) { bulletSpeed = -3f; spriteRenderer.flipX = true; } if (col.gameObject.CompareTag("Player")) { Character_Behaviour playerBehaviour = col.gameObject.GetComponentInParent <Character_Behaviour>(); float differenceX = col.bounds.center.x - GetComponent <Collider2D>().bounds.center.x; playerBehaviour.TakeDamage(damage, differenceX, "Ranged", playerAnimData); Destroy(this.gameObject); } }
void Awake() { behaviour = GetComponent <Character_Behaviour>(); }