Question by
zak666 · Oct 13, 2015 at 03:38 AM ·
scriptingbasics
error CS1525: Unexpected symbol `(', expecting `)', `,', `;', `[', or `='
Funny wait for seconds error, wanting to make the bomb explode after a short time if dons his an enemy*
using UnityEngine;
using System.Collections;
public class Nukje : MonoBehaviour {
public GameObject Explotion;
public void Update (){
yield WaitForSeconds(3);
Explotion = PhotonNetwork.Instantiate("Explotion", transform.position, transform.rotation, 0);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag=="Enemy")
Destroy(gameObject);
Explotion = PhotonNetwork.Instantiate("Explotion", transform.position, transform.rotation, 0);
}
} // END OF CLASS.....................................................................................
Comment
Answer by MadDevil · Oct 13, 2015 at 05:07 AM
You cannot use update as a coroutine.
using UnityEngine;
using System.Collections;
public class Nukje : MonoBehaviour {
public GameObject Explotion;
void Update (){
//yield retWaitForSeconds(3f);
Explotion = PhotonNetwork.Instantiate("Explotion", transform.position, transform.rotation, 0);
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag=="Enemy")
Destroy(gameObject);
Explotion = PhotonNetwork.Instantiate("Explotion", transform.position, transform.rotation, 0);
}
} // END OF CLAS
try keeping the update code in some other function and make that a coroutine if you want delay in it.
Your answer
![](https://koobas.hobune.stream/wayback/20220612041111im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Set public gameobject by raycast hit target 1 Answer
my script was written but does not want to work 1 Answer
Google play services? 0 Answers
need script for launching missile 0 Answers
Acceleration issue 0 Answers