// Applies whatever effect the magic has against the other object. private void applyMagicEffect(Collider2D co) { // Check if the other object has a OnMagicImpact GameObject go = co.gameObject; OnMagicImpact script = go.GetComponent <OnMagicImpact>(); if (script != null) { Debug.Log("Lanzando delegado"); OnMagicImpact.ImpactDetails details = new OnMagicImpact.ImpactDetails(); details.skillName = skill; details.hitPoint = this.transform.position; script.triggerDelegate(details); } }
public void OnMagicImpactEffect(OnMagicImpact.ImpactDetails details) { rb.bodyType = RigidbodyType2D.Dynamic; // Calculate hit force direction. Vector2 batPos = this.transform.position; Vector2 hitDir = batPos - details.hitPoint; rb.AddForce(hitDir.normalized * 200); animator.SetTrigger("onDamage"); animator.updateMode = AnimatorUpdateMode.AnimatePhysics; isDying = true; //Destroy(gameObject); onDestroyEffect = GameObject.Instantiate(onDestroyEffect); onDestroyEffect.transform.position = this.transform.position; }