Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by gavchamp · Jan 18, 2016 at 06:46 AM · unexpected-symbol

Coding Error

So I've been working on a text based game and I just finished writing out the code. I have two current errors in my code. One is CS1525 unexpected symbol '{' which is on line 85. The next error has two occurrences in the code. It is CS0116 a namespace can only contain types and namespace declarations. there is one error on line 89 and 98.

If anyone could help me i'd really appreciate it :D

My code is here:

using UnityEngine; using UnityEngine.UI; using System.Collections;

public class TextController : MonoBehaviour {

 public Text text;
 private enum States {boat, cabin_0, atf, button, cabin_1, key, ulb, lifeboat};
 public States myState;

 // Use this for initialization
 void Start () {
     myState = States.boat;
 }
 
 // Update is called once per frame
 void Update () {
     print (myState);
     if (myState == States.boat)                 {state_boat();}    
     else if (myState == States.cabin_0)         {state_cabin_0();}
     else if (myState == States.atf)                {state_atf();}
     else if (myState == States.button)            {state_button();}
     else if (myState == States.cabin_1)            {state_cabin_1();}
     else if (myState == States.key)                {state_key();}
     else if (myState == States.ulb)             {state_ulb();}    
     else if (myState == States.lifeboat)        {state_lifeboat();}
     
 }    

 void state_boat () {
     text.text = "You are on your boat and all you remember was a sudden bang. You look towords " +
                 "the cabin of the boat only to see it filling with more water by the second. " +
                 "You know that there is a lifeboat on the boat but you need to find out how to " +
                 "activate it.\n\n" +
                 "Press C to look further into the cabin, A to look around the front of the boat and B to " +
                 "investigate the lifeboat button.";
     if (Input.GetKeyDown(KeyCode.C))            {myState = States.cabin_0;}
     else if (Input.GetKeyDown(KeyCode.A))        {myState = States.atf;}    
     else if (Input.GetKeyDown(KeyCode.B))        {myState = States.button;}
 }
 
 void state_cabin_0 () {
     text.text = "You walk into the cabin as water gushes through the hole in the hull " +
                 "You notice that there is a sign that states 'Lifeboat button outside (requires key) " +
                 "\n\n" +
                 "Press R to return to the deck of the boat";
     if (Input.GetKeyDown(KeyCode.R))             {myState = States.boat;}
 
 }
 
 void state_atf () {
     text.text = "You walk around the side of the boad to notice what you have hit, you hit a rock which teared " +
                 "right through the hull. You also notice a lot of junk here with a chest at the end of the boat. " +
                 "\n\n" +
                 "Press L too Look into the chest, press R to return ot the deck of the boat";
     if (Input.GetKeyDown(KeyCode.L))            {myState = States.key;}    
     else if (Input.GetKeyDown (KeyCode.R))        {myState = States.boat;}
 
 }
 
 void state_button() {
     text.text = "You walk over to the end of the boat and notice that there is a button that is locked over by a cover. " +
                 "It is the button to activate the lifeboat, the only problem is you need to find the key somewhere. " +
                 "I hope that it didnt fall off the edge!\n\n" +
                 "Press R to return ot the deck of the boat";
     if (Input.GetKeyDown (KeyCode.R))            {myState = States.boat;}
     
 }
 
 void state_cabin_1() {
     text.text = "You walk back into the cabin to find that the water is now reaching your knee, you need to act fast and " +
                 "get that lifeboat on the water before the boat goes under! " +
                 "\n\n" +
                 "Press R to return to the crate around the front of the boat";
     if (Input.GetKeyDown (KeyCode.R))            {myState = States.key;}
     
 }
 
 void state_key() {
     text.text = "You open the lid of the crate and theres boxes everywhere you pick out one box in particular the box says" +
                 " 'USE ONLY IN AN EMERGENCY' You crack it open and find the key to the lifeboat button as well as some first aid and flares " +
                 "\n\n" +
                 "Press C to look in the cabin again, press B to go to the unlock Button";
     if (Input.GetKeyDown(KeyCode.C))            {myState = States.cabin_1;}
     else if (Input.GetKeyDown(KeyCode.B)        {myState = States.ulb;}
     
 }
 
 void state_ulb () {
     text.text = "You run down the side of the boat, you get the key out of your pocket and insert it into the key slot and turn it. " +
                 "You feel a sense of relief as it unlocks the lid of the button. " +
                 "\n\n" +
                 "Press L activate the Lifeboat";
     if (Input.GetKeyDown (KeyCode.L))            {myState = States.lifeboat;}
                     
 }
 
 void state_lifeboat () {
     text.text = "You hit the button and you can see the lifeboat fall out the side of the boat you feel reallt happy and you jump into the boat and paddle away" +
                 "\n\n" +
                 "Press R to restart the game you won :D";    
     if (Input.GetKeyDown (KeyCode.R))            {myState = States.boat;}
     
 }
     

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by UsmanAbbasi · Jan 18, 2016 at 06:55 AM

"CS1525 unexpected symbol '{' " this error is causing next 2 errors. If you resolve this you will get rid of other two errors also. You are missing "}" somewhere or you have an additional "{" somewhere. Your code is not indented properly which is making it difficult for me to look for missing braces. Indent it properly and then repost it so people can help you.

Comment
Add comment · 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

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

37 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why is my '(' an unexpected symbol? 0 Answers

Why do I have errors on all of my private declarations and on my void update? 1 Answer

Unexpected symbol error 0 Answers

Error CS1519 help 1 Answer

Unexpected symbol `object' in class, struct, or interface member declaration. 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