} expected issue

Im Stuck on this as it says I’m missing a } but am unsure as to where to put it. any help? 6971111--821831--upload_2021-3-24_23-13-22.png

You are missing the opening and closing brace for the class body. Add (“{” line 6, “}” line 41)

2 Likes

How to understand compiler and other errors and even fix them yourself:

https://discussions.unity.com/t/824586/8

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: https://discussions.unity.com/t/481379

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

1 Like

Im sorry, I’m very new to unity and C# and I’ve added it and the errors are still there, any fixes. sorry.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAttack : MonoBehaviour

     public Camera cam;
     public GameObject Hand;
     public Weapon myWeapon;
     Animation handAnim;

     void Start() {
        handAnim = Hand.GetComponent<Animator>();
         myWeapon = Hand.GetComponentInChildren<Weapon>();
     }
     
   
     void Update() {
       if(Input.GetMouseButtonUp(0))
       {
          DoAttack();
       }
     }
    
     private void DoAttack()
     {

         Ray ray = cam.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;

         if(Physics.Raycast(ray , out hit, myWeapon.attackRange))
         {

            if(hit.collider.tag = "Enemy")
            {
                EnemyHealth. eHealth = hit.collider.GetComponent<EnemyHealth>();
                eHealth.TakeDamage(myWeapon.attackDamage);
            }
         }  
     }
//end o class ("{"line 6,"}" line 41")

yeah but where is “{” on line 6

and why you copy and paste (“{” line 6, “}” line 41) on line 41
that is not what spryx want you to do
you write: { ,at line 6 and, } at line 41

thanks

1 Like