using UnityEngine;
public class weapon : MonoBehaviour
{
public float damage = 10f;
public Camera fpsCam;
void FixedUpdate()
{
if (Input.GetButton("Fire1"))
{
Shoot();
}
}
void Shoot()
{
RaycastHit hit;
if(Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward,out hit))
{
Target target = hit.transform.GetComponent<Target>();
if(target != null)
{
target.TakeDamage(damage);
}
}
}
}
In my script this is attached to my player. The player shoots a raycast. It should damage GameObjects with the script target on them .The function Take Damage should execute and apply damage but getting :
error CS0246: The type or namespace name ‘Target’ could not be found (are you missing a using directive or an assembly reference?)
PLS HELP!!!