error: Assets/scripts/Gamemaneger.cs(27,51): error CS1525: Unexpected symbol `)'
PLEASE HELP
using UnityEngine;
using System.Collections;
using System;
public class Gamemaneger : MonoBehaviour {
public Transform Platformgenerator;
private Vector3 platformStartpoint;
public player thePlayer;
private Vector3 playerStartPoint;
// Use this for initialization
void Start () {
platformStartpoint = Platformgenerator.position;
playerStartPoint = thePlayer.transform.position;
}
// Update is called once per frame
void Update ()
{ }
private void Start(Func<IEnumerator> RestartGame)
{
Gamemaneger.StartCoroutine(RestartGameCo);
}
public IEnumerator RestartGameCo()
{
thePlayer.gameObject.SetActive(false);
yield return new WaitForSeconds(0.5f);
thePlayer.transform.position = playerStartPoint;
Platformgenerator.position = platformStartpoint;
thePlayer.gameObject.SetActive(true);
}
}
error: Assets/scripts/Gamemaneger.cs(27,51): error CS1525: Unexpected symbol ` ) '
Answer by corn · Jan 09, 2016 at 08:13 PM
There's two problems in your private Start method.
First, a syntax error : StartCoroutine(RestartGameCo);
should be StartCoroutine(RestartGameCo());
Gamemaneger.StartCoroutine
should just be StartCoroutine
. You probably meant to use this.StartCoroutine
, but this.xxx
and Gamemaneger.xxx
are not the same thing. Gamemaneger.xxx
is the syntax for accessing static (class) methods or variables, while this
refers to the current instance of Gamemanager. However, this
is optional in C# while accessing a field or method.
So what you should write is :
private void Start(Func<IEnumerator> RestartGame)
{
StartCoroutine(RestartGameCo());
}
Your answer
Follow this Question
Related Questions
Error pls help 1 Answer
System Equipment and Changing Clothes in 2d Endless Runner Game ? 0 Answers
One question... 0 Answers
How to add a restart to my 2D game? 0 Answers
Scenes don't repeat themselves after pressing a restart button 1 Answer