Quantcast
Channel: Questions in topic: "namespace"
Viewing all articles
Browse latest Browse all 398

The type or namespace "Target" could not be found?

$
0
0
I'm getting this error message from this code: 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); // This is where the error is Target target = hit.transform.GetComponent(); } } } I already made sure i didn't spell Target wrong. I also tried the stuff with moving scripts between folders, but it didn't work. Anyone know some other fix?

Viewing all articles
Browse latest Browse all 398

Trending Articles