void ShootInstaHitZap(float intendedDamage) { //needed to damage enemy skaterBehaviour skaterStats = target.GetComponent <skaterBehaviour>(); //do zapper stuff lightningZap.enabled = true; lightningZap.StartObject = firePoint; //get the point of impact on enemy Vector3 enemyDir = target.transform.position - firePoint.position; float enemySurfaceDist = Mathf.Clamp(enemyDir.magnitude, enemyDir.magnitude - 2, enemyDir.magnitude - target.GetComponent <Renderer>().bounds.size.x); Vector3 enemyHitPoint = enemyDir.normalized * enemySurfaceDist; //use target.transform for now (need change in lightning script maybe) lightningZap.EndObject = target.transform; float zapDuration = (1f / TB.attackrate) / 2f; lightningZap.Duration = Mathf.Clamp(zapDuration, 0.03f, 0.2f); ln.enabled = true; lightningZap.Trigger(); //StartCoroutine(fadeLigtning((1 / TB.attackrate) / 2)); //instatiate effect at lightningZap.endPosition skaterStats.TakeDamage(intendedDamage); }
void hitTarget() { Debug.Log("The bullet hit " + target.name); if (hitEffect != null) { GameObject effectInstance = (GameObject)Instantiate(hitEffect, transform.position, transform.rotation); Destroy(effectInstance, 4f); } Destroy(gameObject); skaterBehaviour targetsStats = target.GetComponent <skaterBehaviour>(); targetsStats.TakeDamage(damage); }