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.PlayOneShot (audioSource.clip);
// TODO: Deduct gold
}
}
}
}
Please help
↧