public override void DoAttack() { //if target == null -> target.pos = pos in front of player/weapon Vector3 targetPos = (target != null ? target.position : (transform.position + 10 * transform.forward)); Vector3 direction = targetPos - transform.position; GameObject ammo = Instantiate(ammoType); // direction += ammo.transform.rotation.eulerAngles; //ammo.transform.position = transform.position + transform.rotation * Vector3.forward * 2; ammo.transform.position = positionOffset.position;// + transform.rotation * Vector3.forward * 0.5f; //for arrow ammo.transform.rotation = Quaternion.LookRotation(direction); //Projectile pro = ammo.GetComponent<Projectile>(); StraightProjectile pro = ammo.GetComponent <StraightProjectile>(); pro.attack(targetPos); }
void OnTriggerEnter(Collider other) { StraightProjectile pro = GetComponentInParent <StraightProjectile>(); if (pro != null) { if (pro.TagList.IsTagNotHitable(other.tag)) { return; } } if (other.GetComponent <SlimeBase>() != null) { return; } if (other.GetComponent <IDamageable>() != null) { _burnEvent.InvokeSpecificListner(other.gameObject.GetInstanceID()); } }
private void Start() { _projectile = new StraightProjectile(transform); _health = 3; }