- Home /
 
Unexpected symbol '{ ,= ,; in, ), !=, && ,== ,< , etc. etc.' in class, struct, or interface member declaration.
So, I've been following this tutorial (https://www.youtube.com/watch?v=EyRPmhyrVUs) on Raycast shooting in Unity, and I can't figure out why this is happening. Here's my code:
using UnityEngine; using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
 // Use this for initialization
 void Start () {
     if (Input.GetButton ("Fire1")) {
     }
 }
 
 // Update is called once per frame
 void Update () {
 
 }
 void Fire () {
     Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
     Transform hitTransform;
     Vector3 hitPoint;
     FindClosestTransform(ray, hitPoint);
 }
 Transform FindClosestTransform(Ray ray, out Vector3 hitPoint); {
     RaycastHit[] hits = Physics.RaycastAll (ray);
     Transform closestHit = null;
     float distance = 0;
     hitPoint = Vector3.zero;
     foreach (RaycastHit hit in hits) {
         if(hit.transform != this.transform && (closestHit == null || hit.distance < distance)) {
             closestHit = hit.transform;
             distance = hit.distance;
             hitPoint = hit.Point;
         }
     }
     Debug.Log("We just hit: " + closestHit.name + " with a BLANK");
     return closestHit;
 }
 
               }
Where ever it says "= hit", whether that be 'closestHit = hit.transform;' or 'distance = hit.distance;' or 'hitPoint = hit.Point;', there's a red line. It says it's an unexpected symbol. There's also one where it says "= Vector3.zero" between the '=' and 'Vector3'. So, that led me to believe it was just those that were 'unexpected'. But, when I had looked at my Console, I got tons and tons of Compiler Error that all said the same unexpected symbol thing. This time though, it was with lots of operators. Ex: '{ ,= ,; in, ), !=, && ,== ,< , etc. etc.' Can anyone help? I am a super noob with Unity and C#, as you may have been able to tell.
Unity version: 5.0.2f1 Personal
Raycasting involves some tricky computer principles. The best way to learn it is to start with any basic C# / program$$anonymous$$g book. In the long run, learning program$$anonymous$$g will save time, from making trial and error tweaks and trying to fix errors otherwise.
Answer by tanoshimi · Jun 09, 2015 at 12:31 PM
 Transform FindClosestTransform(Ray ray, out Vector3 hitPoint); {
 
               What's that semicolon doing there?
Sorry, I've fixed this. Well, started a new tutorial that helped much more. So, thank you to anyone who replied.
Your answer
 
             Follow this Question
Related Questions
Raycast damage script 2 Answers
change to raycast shooting instead of rigidbody shooting 1 Answer
Raycast Shooting problem 2 Answers
Raycast Shooting Help 1 Answer
NEED HELP WITH RAYCAST SHOOTING !!! 1 Answer