Here is my code:
using UnityEngine;
using System.Collections;
public class Difficulty : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
GameObject thePlayer = GameObject.Find("_scorer");
score score = thePlayer.GetComponent<score>();
GameObject spawnerobject = GameObject.Find("spawn 1");
spawner spawner = spawnerobject.GetComponent<spawner>();
if (score.theScore >= 100) {
spawner.Difficulty2 ();
}
return Update();
}
}
and for the other script:
using UnityEngine;
using System.Collections;
public class spawner : MonoBehaviour {
public int Wait_time;
public Transform CUBE;
// Use this for initialization
void Start () {
Wait_time = Random.Range (1, 5);
StartCoroutine (waiter ());
}
// Update is called once per frame
void Update () {
}
IEnumerator waiter()
{
yield return new WaitForSeconds (Wait_time);
spawn();
}
void spawn()
{
Transform temp = Instantiate(CUBE, transform.position,Quaternion.identity) as Transform;
StartCoroutine (waiter ());
}
public void Difficulty2 ()
{
StartCoroutine (Difficultyset ());
}
IEnumerator Difficultyset()
{
Wait_time = Random.Range (1, 4);
spawn ();
}
}
I get this for some reason:
Assets/Difficulty.cs(20,17): error CS0127: `Difficulty.Update()': A return keyword must not be followed by any expression when method returns void
i have tried taking off the return but then i get this error:
Assets/spawner.cs(36,21): error CS0161: `spawner.Difficultyset()': not all code paths return a value
I dont have any clue of whats going wrong can someone come up with a solution to this problem.
Scott.