Question by
RAINV7 · Sep 05, 2015 at 08:42 AM ·
coroutine errors
Update() can not be a coroutine
Hey! This is the script:
#pragma strict
var Sound : AudioClip;
var coll: Collider;
function Start() {
coll = GetComponent.<Collider>();
}
function Update(){
// Move this object to the position clicked by the mouse.
if (Input.GetMouseButtonDown(0)) {
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if (coll.Raycast(ray, hit, 100.0)) {
GetComponent.<AudioSource>().PlayOneShot(Sound);
}
{
yield WaitForSeconds (1);
}
{
Application.LoadLevel("EasterEggThingy");
transform.position = ray.GetPoint(100.0);
}
}
}
I have tried the other solutions from other questions but I just can't fix it. Can someone help me with this code?
Comment
You can't yield Update 'yield WaitForSeconds (1);'
If you want to do something after a delay, you need to make a new function that you yield, or measure time passed in some other way.
Also you have a load of see$$anonymous$$gly random curly brackets '{' doing nothing of particular interest!
Your answer
Follow this Question
Related Questions
Errors using StopCoroutine with nested coroutines 1 Answer
firebase analytics freeze inside coroutine 0 Answers
Add points every five seconds 1 Answer
Coroutine Not working properly. 1 Answer