i dont know what to do, i think im stupid.
Error:
Assets\Gun.cs(24,24): error CS1061: 'Target' does not contain a definition for 'TakeDamage' and no accessible extension method 'TakeDamage' accepting a first argument of type 'Target' could be found (are you missing a using directive or an assembly reference?)
using UnityEngine;
public class Gun : MonoBehaviour
{
public float damage = 10f;
public float range = 100f;
public Camera fpsCam;
// Update is called once per frame
void Update()
{
if(Input.GetButtonDown("Fire1")){
Shoot();
}
}
void Shoot (){
RaycastHit hit;
if(Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{
Debug.Log(hit.transform.name);
Target target = hit.transform.GetComponent<Target>();
if(target != null)
{
target.TakeDamage(damage);
}
}
}
}