I
I
Ivan Zhuk2022-02-04 15:22:13
C++ / C#
Ivan Zhuk, 2022-02-04 15:22:13

Error in unity c# script?

Gives error
Assetsigun.cs(29,13): error CS0246: The type or namespace name 'Target could not be found (are you missing a using directive or an assembly reference?)

void Shoot(){

            RaycastHit hit;
          if(Physics.Raycast(fpsCam.transform.position,fpsCam.transform.forward, out hit, range)){

            Target enemy = hit.transform.GetComponent<enemy>();   

                if(enemy != null){
                    enemy.TakeDamage(damage); // ete enemy ka uremny kyanqery khani
                }

          } 

    }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
@
@insighter, 2022-02-04
@ivanzuk761

write var instead of Target, does it compile?

F
freeExec, 2022-02-04
@freeExec

I acknowledge the error and agree with its content. I don't know who Target is, nor is he.

M
Morrowind, 2022-02-04
@hekkaaa

Apparently you need to include the namespace via using for the Tagret class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question