So I am trying to make a hitscan laser weapon, from what I seen the weapon it self seems to be working. But I don't know how to make the ray visiable, I tried understanding line renderer but frankly I have no idea what I'm doing. Any tips?(This is the raycast code)
using System.Collections.Generic;
using UnityEngine;
public class Weapon : MonoBehaviour
{
private float damage = 10;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("k"))
{
Shoot();
}
}
void Shoot()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.forward, out hit, Mathf.Infinity))
{
Health target = hit.collider.GetComponent<Health>();
if (target != null)
{
target.TakeDamage(damage);
}
}
}
}```