void damage(Transform baddie) //entire transform { Baddie baddieScript = baddie.GetComponent <Baddie>(); if (baddieScript != null) { //hurt the enemy baddieScript.takeDamage(bulletDamage); } }
void lazer() { //damage baddie targetBaddie.takeDamage(damageOverTime * Time.deltaTime); //slow baddie targetBaddie.slow(slowPercentage); if (!lazerLineRenderer.enabled) { lazerLineRenderer.enabled = true; impactEffect.Play(); //play partciles impactLight.enabled = true; //play light } lazerLineRenderer.SetPosition(0, firePoint.position); lazerLineRenderer.SetPosition(1, target.position); //set particles on baddie Vector3 dir = firePoint.position - target.position;//point from baddie back towards turret //set position on baddie nbody impactEffect.transform.position = target.position + dir.normalized;//0.5f because the baddie size is 1. TODO: generalize this to just use targets scale / 2 //rotate towards the turret so the particles are like "shooting" off the body impactEffect.transform.rotation = Quaternion.LookRotation(dir); }