using UnityEngine;
public class Lightning : MonoBehaviour
{
public float damage;
Vector3 Lightingspeed;
public float speed = 50f;
public float radius = 5;
public GameObject Lightning;
public LineRenderer lineRenderer;
void Start()
{
lineRenderer lineRenderer = gameObject.AddComponent<lineRenderer>();
Lightingspeed = this.transform.forward * speed;
}
void OnCollisionEnter(Collision col)
{
Debug.Log("shocked");
Collider[] hitColliders = Physics.OverlapSphere(transform.position, radius);
foreach (Collider hitCol in hitColliders)
{
Debug.Log(hitCol.gameObject.name);
EnemyHealth enemyHealth = hitCol.transform.GetComponent<EnemyHealth>();
if (enemyHealth != null)
{
enemyHealth.TakeDamage(damage);
Debug.Log(damage);
}
}
}
}
I’m trying to shoot a projectile that cast an overlapshere on hit and store a list of targets for the spell to bounce between. I’m not sure how to make the linerender follow the collider array.