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 importguru88 · Sep 11, 2016 at 10:23 PM · scripting problemerrorscript errorcompiler

(31,16): error CS1525: Unexpected symbol `(', expecting `)', `,', `;', `[', or `='

I am trying to pause and unpause a gameobject in my scene . I need it pause by itself not by pressing a key. I am have some problems getting the code together . Two of the same errors :

(31,16): error CS1525: Unexpected symbol (', expecting )', ,', ;', [', or =' (56,16): error CS1525: Unexpected symbol (', expecting )', ,', ;', [', or ='

 using UnityEngine;
 using System.Collections;
 
 public class star : MonoBehaviour {
 GameObject[] pauseObjects;
 
 
     void Start () {
     pauseObjects = GameObject.FindGameObjectsWithTag("Player");
     }
     
 void Pause(){
   StartCoroutine(waitToUnpause);
 }
 
 IENumerator waitToUnpause(){
   //do the thing to pause game
   Time.timeScale = 7f;//or some other method
   yield return new WaitForSeconds(7);///or any duration you want
   Time.timeScale = 1f;//or some other method
 }
 
 void pauseGameobject()
 
 {
  timeLeft -= Time.deltaTime;
 if(timeLeft < 0)
 gameObject.SetActive(false);
 {
 
 start coroutine("wait");
 
 }
 
 }
 
 public ienumenator wait()
 
 {
 
 time.timescale = 0;
 
 yield return new waitforsceonds(7);
 
 time.timesale = 1;
 
 }
 void pauseGameobject()
 
 {
 
 if(timerleft < 0)
 
 {
 
 start coroutine("wait");
 
 }
 
 }
 
 public ienumenator wait()
 
 {
 
 time.timescale = 0;
 
 yield return new waitforsceonds(7);
 
 time.timesale = 1;
 
 }
 
 }
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 ScaniX · Sep 11, 2016 at 10:48 PM 0
Share

You really need to check your code for typos. Remember that the compiler needs to have the identifiers written in the correct way. All method or variable names need to be written without spaces and using the correct case for all letters.

You have a bunch of typos in there that anyone can see right away without using an ID$$anonymous$$ Visual Studio should mark all those places for you, just proof read them and the errors should be easy to fix.

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Spade0 · Sep 12, 2016 at 12:28 AM

I have cleaned up your code for you. You should really watch some videos on C# best practices. You have declared the same things multiple times and they require different names. I'm sorry to say that your spelling and typos are quite extensive.

Please take better care when your writing code in the future... attention to detail! Below is your code ↓ I hope you can learn something from it and apply it.

PS. Your code still missing a lot of things to make this do much of anything... Best of luck.

 using UnityEngine;
 using System.Collections;
 
 public class star : MonoBehaviour {
     
     GameObject[] pauseObjects;
     public float timeLeft;
 
     void Start () 
     {
         pauseObjects = GameObject.FindGameObjectsWithTag("Player");
     }
 
     public void Pause()
     {
         StartCoroutine(waitToUnpause());
     }
 
     IEnumerator waitToUnpause()
     {
         //do the thing to pause game
         Time.timeScale = 7f;//or some other method
         yield return new WaitForSeconds(7);///or any duration you want
         Time.timeScale = 1f;//or some other method
     }
 
     public void pauseGameobject()
 
     {
         timeLeft -= Time.deltaTime;
         if(timeLeft < 0)
         gameObject.SetActive(false);
         {
             StartCoroutine(wait());
         }
     }
 
     IEnumerator wait()
     {
         Time.timeScale = 0;
         yield return new WaitForSeconds(7);
         Time.timeScale = 1;
     }
 }

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
avatar image
1

Answer by gjf · Sep 11, 2016 at 10:25 PM

check the syntax of start coroutine("wait"); on both lines... you've got it right on line 13

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 importguru88 · Sep 11, 2016 at 10:33 PM 0
Share

I had fixed the errors . I have more errors now .

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

79 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 5 checking if player isGrounded 1 Answer

All scripts in unity give the error "the associated script can not be loaded please fix any compile errors and assign a vaild script" 4 Answers

Referencing another script error/problem 0 Answers

error CS1526: A new expression requires () or [] after type 1 Answer

error CS1525: Unexpected symbol `' 2 Answers


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