Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 /
This question was closed Jul 05, 2015 at 11:31 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Grge · Jul 05, 2015 at 10:34 AM · unexpectedsymbol

error CS1525: Unexpected symbol `}'

Hi just need a little help with this error. I have had it before due to the incorrect number of brackets and have thus been able to sort it but this time I have the correct number of opening and closing brackets but its still coming up.

The origin of this script is from this tutorial http://stormtek.geek.nz/rts_tutorial/part6.php and these errors have come at the end of part 6.

Assets/Player/UserInput.cs(130,41): error CS1525: Unexpected symbol `}'

using UnityEngine; using System.Collections; using RTS;

public class UserInput : MonoBehaviour {

 private Player player;


 // Use this for initialization
 void Start () 
 {
     player = transform.root.GetComponent< Player >();
 
 }
 
 // Update is called once per frame
 void Update () 
 {
     if(player.human) 
     
         MoveCamera ();
         RotateCamera ();
     MouseActivity ();
     
     
 }
     private void MoveCamera () 
 {
     float xpos = Input.mousePosition.x;
     float ypos = Input.mousePosition.y;
     Vector3 movement = new Vector3 (0, 0, 0);

     //horizontal camera movement
     if (xpos >= 0 && xpos < ResourceManager.ScrollWidth) 
     {
         movement.x -= ResourceManager.ScrollSpeed;
     } else if (xpos <= Screen.width && xpos > Screen.width - ResourceManager.ScrollWidth) 
     {
         movement.x += ResourceManager.ScrollSpeed;
     }
 
 //vertical camera movement
 if (ypos >= 0 && ypos < ResourceManager.ScrollWidth) 
 {
     movement.z -= ResourceManager.ScrollSpeed;
 }
 else if (ypos <= Screen.height && ypos > Screen.height - ResourceManager.ScrollWidth) 
 {
     movement.z += ResourceManager.ScrollSpeed;
 }

     //make sure movement is in the direction the camera is pointing 
     //but ignore the vertical tilt of the camera to get sensible scrolling
     movement = Camera.main.transform.TransformDirection (movement);
     movement.y = 0;

     //away from ground movement
     movement.y -= ResourceManager.ScrollSpeed * Input.GetAxis ("Mouse ScrollWheel");

     //calculate desired camera position based on received input
     Vector3 origin = Camera.main.transform.position;
     Vector3 destination = origin;
     destination.x += movement.x;
     destination.y += movement.y;
     destination.z += movement.z;

     //limit away from ground movement to be between a minimum and maximum distance

     if (destination.y > ResourceManager.MaxCameraHeight) 
     {
         destination.y = ResourceManager.MaxCameraHeight;
     } 
     else if (destination.y < ResourceManager.MinCameraHeight)
     {
         destination.y = ResourceManager.MinCameraHeight;
     }

     //if a change in position is detected perform the necessary update
     if (destination != origin) {
         Camera.main.transform.position = Vector3.MoveTowards (origin, destination, Time.deltaTime * ResourceManager.ScrollSpeed);
     }
     }

     private void RotateCamera () 
     {
     Vector3 origin = Camera.main.transform.eulerAngles;
     Vector3 destination = origin;
 

     //detect rotation amount if ALT is being held and the Right mouse button is down
     if ((Input.GetKey (KeyCode.LeftAlt) || Input.GetKey (KeyCode.RightAlt)) && Input.GetMouseButton (1)) {
         destination.x -= Input.GetAxis ("Mouse Y") * ResourceManager.RotateAmount;
         destination.y += Input.GetAxis ("Mouse X") * ResourceManager.RotateAmount;
     }

     //if a change in position is detected perform the necessary update
     if (destination != origin) {
         Camera.main.transform.eulerAngles = Vector3.MoveTowards (origin, destination, Time.deltaTime * ResourceManager.RotateSpeed);
     }
 }
 private Vector3 FindHitPoint() {
     Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
     RaycastHit hit;
     if (Physics.Raycast (ray, out hit))
         return hit.point;
     return ResourceManager.InvalidPosition; 
 }

 private void MouseActivity() 
 {
     if (Input.GetMouseButtonDown (0)) LeftMouseClick();
     else if (Input.GetMouseButtonDown(1)) RightMouseClick();
 }
 private void LeftMouseClick() {
     if (player.hud.MouseInBounds ()) {
         GameObject hitObject = FindHitObject ();
         Vector3 hitPoint = FindHitPoint ();
         if (hitObject && hitPoint != ResourceManager.InvalidPosition) {
             if (player.SelectedObject)
                 player.SelectedObject.MouseClick (hitObject, hitPoint, player);
             else if (hitObject.name != "Ground") {
                 WorldObject worldObject = hitObject.transform.root.GetComponent< WorldObject > ();
                 if (worldObject) {
                     //we already know the player has no selected object
                     player.SelectedObject = worldObject;
                     worldObject.SetSelection (true);
                     player.hud.GetPlayingArea()

                 }
             }
         }
     }
 }

 private void RightMouseClick(){
     if (player.hud.MouseInBounds () && !Input.GetKey (KeyCode.LeftAlt) && player.SelectedObject) {
         player.SelectedObject.SetSelection (false);
         player.SelectedObject = null;
         player.hud.GetPlayingArea()
             
     }
 }
     private GameObject FindHitObject() {
         Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast (ray, out hit))
             return hit.collider.gameObject;
         return null;
     }
 }
Comment
Add comment · Show 2
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 Grge · Jul 05, 2015 at 09:12 AM 0
Share

This error also comes up - Assets/Player/UserInput.cs(142,17): error CS1525: Unexpected symbol `}'

avatar image fafase · Jul 05, 2015 at 10:39 AM 0
Share

You have one } too many or too few. Indent your code next time.

1 Reply

  • Sort: 
avatar image
4
Best Answer

Answer by tanoshimi · Jul 05, 2015 at 10:40 AM

Error messages are written to help you. When you get an error that says "Unexpected symbol", it's worth looking at your code and thinking "Well, if "}" wasn't what Unity was expecting, what was it expecting?".

Look at the sections of code indicated by the error messages. You'll see that you have the same line of code, with the same mistake in it, in both cases:

 player.hud.GetPlayingArea()

Statements need to be terminated by a semicolon. So, Unity was expecting to find a ; after GetPlayingArea(), but the next character it found (which is on the following line) was a }. That's what Unexpected symbol `}' means.

Comment
Add comment · Show 1 · 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 Grge · Jul 05, 2015 at 11:17 AM 0
Share

Thanks tanoshimi that fixed the problem.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

unexpected symbol 'private' 0 Answers

CS1525: 60,68 Unexpected symbol MatchMaxPlayers 1 Answer

Quill18's Tutorial Scripts: Unexpected Symbols 1 Answer

Error unexpected symbol 'internal' What is wrong with this? 0 Answers

Unexpected symbol, "Projectile" while attempting to delete gameObject.Projectile 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