locked
Only assignment, call, increment, decrements, and new object expressions can be used as a statement RRS feed

  • Question

  • Getting an error:Only assignment, call, increment, decrements, and new object expressions can be used as a statement

    using UnityEngine;

    public class SpawnEnemies : MonoBehaviour
    {
        private float nextSpawnTime;
        public GameObject Enemies;
        public float spawnDelay;
     
        // Use this for initialization
     void Start ()
        {
      
     }
     
     // Update is called once per frame
     void Update ()
        {
      if (shouldspawn())
            {
                spawn;
            }
     }
        public void spawn()
        {
            nextSpawnTime = Time.time + spawnDelay;
            Instantiate(Enemies, transform.position, transform.rotation);
        }
        public bool shouldspawn()
        {
            return Time.time >= nextSpawnTime;
        }
    }


    • Edited by RandomBoi Thursday, August 2, 2018 9:18 AM Error
    Thursday, August 2, 2018 9:12 AM

Answers

  • To call spawn, write spawn().


    • Marked as answer by RandomBoi Thursday, August 2, 2018 10:40 AM
    Thursday, August 2, 2018 10:38 AM

All replies