(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;
}
}
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.
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;
}
}
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