Help: Assets/scripts/Gamemaneger.cs(34,9): error CS0428: Cannot convert method group `FindObjectOfType' to non-delegate type `PlatformDeystoyer[]'. Consider using parentheses to invoke the method
Assets/scripts/Gamemaneger.cs(34,9): error CS0428: Cannot convert method group FindObjectOfType' to non-delegate type
PlatformDeystoyer[]'. Consider using parentheses to invoke the method
script:
using UnityEngine; using System.Collections; using System;
public class Gamemaneger : MonoBehaviour {
public Transform Platformgenerator;
private Vector3 platformStartpoint;
public player thePlayer;
private Vector3 playerStartPoint;
private PlatformDeystoyer[] platformlist;
// Use this for initialization
void Start () {
platformStartpoint = Platformgenerator.position;
playerStartPoint = thePlayer.transform.position;
}
// Update is called once per frame
void Update ()
{ }
public void RestartGame()
{
StartCoroutine(RestartGameCo());
}
public IEnumerator RestartGameCo()
{
thePlayer.gameObject.SetActive(false);
yield return new WaitForSeconds(0.5f);
platformlist = FindObjectOfType<PlatformDeystoyer>; **//here should be the error according to visual studio**
for (int i = 0; i < platformlist.Length; i++)
{
platformlist[i].gameObject.SetActive(false);
}
thePlayer.transform.position = playerStartPoint;
Platformgenerator.position = platformStartpoint;
thePlayer.gameObject.SetActive(true);
}
}
Answer by whalan84 · Jan 10, 2016 at 02:18 PM
I am only a beginner but I have a feeling you may just need to add parentheses to the end of FindObjectOfType such as below
platformlist = FindObjectOfType<PlatformDeystoyer>();
Jason.
I am following this tutorial to learn the basics:
No worries. I edited the post as I had incorrect code... try replacing that one line of code with what I provided above. I have a feeling that may help. Good luck.
I worked but now I have this error:
Assets/scripts/Gamemaneger.cs(34,9): error CS0029: Cannot implicitly convert type PlatformDeystoyer' to
PlatformDeystoyer[]'
Your answer
Follow this Question
Related Questions
Error pls help 1 Answer
Object pooling system. Objects aren't spawning 0 Answers
Stop Point objects respawning when reloading level 0 Answers
Endless runner 1 Answer
error: Assets/scripts/Gamemaneger.cs(27,51): error CS1525: Unexpected symbol `)' 1 Answer