Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Frostbyte6686 · Jun 09, 2015 at 12:29 PM · raycastshootingcompiler errorunexpected-symbol

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Owen-Reynolds · Jun 09, 2015 at 08:47 PM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by tanoshimi · Jun 09, 2015 at 12:31 PM

 Transform FindClosestTransform(Ray ray, out Vector3 hitPoint); {

What's that semicolon doing there?

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image KdRWaylander · Jun 09, 2015 at 01:04 PM 0
Share

"A man is right" -Jaqen H'ghar (Faceless man)

avatar image Frostbyte6686 · Jun 10, 2015 at 03:27 AM 0
Share

Sorry, I've fixed this. Well, started a new tutorial that helped much more. So, thank you to anyone who replied.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges