public bool ReceiveImpact(AvatarBullet bullet) { //TODO: pasa el daño foreach (var enemyComp in GetComponents <Enemy>()) { enemyComp.ReceiveAvatarBulletImpact(bullet); } return(true); }
public void ReceiveAvatarBulletImpact(AvatarBullet bullet) { if (!inmortal) { animator.SetTrigger("TakeDamage"); life -= bullet.damage; if (life <= 0) { Die(); } } //TODO: animacion de hit }
//llamado desde animacion public void SpawnBullet() { if (cosestTarget == null) { return; } AvatarBullet newBullet = Instantiate <AvatarBullet>(bulletPrefab); newBullet.transform.position = (bulletOrigin != null) ? bulletOrigin.position : transform.position; Vector3 targetPos = new Vector3( cosestTarget.transform.position.x, newBullet.transform.position.y, cosestTarget.transform.position.z); newBullet.transform.LookAt(targetPos, Vector3.up); Debug.DrawLine(transform.position, cosestTarget.transform.position, Color.red, 0.1f); cosestTarget = null; }