Question by
shashwat2001 · Jun 02, 2016 at 11:12 AM ·
errorcs1525
how to fix unexpected symbol 'MonsterPrefab' error CS1525 for a tower survival game
I tried using this code in c sharp script but could not get the script to work. It always kept saying ,"Assets/PlaceMonster.cs(8,52): error CS1525: Unexpected symbol 'MonsterPrefab', expecting '(',')',',',';','[','{', or '' using UnityEngine; using System.Collections;
public class PlaceMonster : MonoBehaviour {
// Use this for initialization
void Start () {
new GameObject MonsterPrefab;
new GameObject Monster;
private bool canPlaceMonster ()
{
return Monster == null;
}
//1s
void OnMouseUp ()
{
//2
if (canPlaceMonster ()) {
//3
Monster = (GameObject)
Instantiate (MonsterPrefab, transform.position, Quaternion.identity);
//4
AudioSource audioSource = gameObject.GetComponent<AudioSource> ();
audioSource.PlayOneShot (audioSource.clip);
// TODO: Deduct gold
}
}
}
}
Please help
Comment
Answer by Prasanna · Jun 02, 2016 at 11:51 AM
This script is not fully formatted. Try to re-format, then check your start function curly bracket(close).
Your answer