Quantcast
Channel: Questions in topic: "unity3.5"
Viewing all articles
Browse latest Browse all 122

Help: script that worked don't work with Unity 3.5

$
0
0
Hello everyone, I need help with a spawnscript I made that worked earlie,r but with the recent updates on Unity, it does not seems to work. Here's the script: using UnityEngine; using System.Collections; public class SpawnScript : MonoBehaviour { public int AmountEnemyInWave; public float SpawnCountdown = 1.0f; public GameObject[] spawnPoints; public GameObject[] enemy; private float SpawnTimer; private int CurrentEnemyNumber = 0; private bool hasFinished = false; void Start() { SpawnTimer = 0.0f; } void SpawnEnemy() { if(!hasFinished) { SpawnTimer += Time.deltaTime; // Debug.Log("SpawnTimer value " + SpawnTimer); // Debug.Log("SpawnCountdown value " + SpawnCountdown); // Debug.Log("SpawnTimer value >= SpawnCountdown value : " + (SpawnTimer >= SpawnCountdown)); if(SpawnTimer >= SpawnCountdown) { // Debug.Log ("Hi darling"); Debug.Log(enemy[0]); Debug.Log(spawnPoints[0]); Instantiate(enemy[0], (spawnPoints[0].transform.position), (spawnPoints[0].transform.rotation)); CurrentEnemyNumber += 1; SpawnTimer = 0.0f; } } } void Update() { SpawnEnemy(); if(CurrentEnemyNumber >= AmountEnemyInWave) { // Debug.Log("CurrentEnemyNumber >= AmountEnemyInWave : " + (CurrentEnemyNumber >= AmountEnemyInWave)); hasFinished = true; } } } Notice that all the Debug.Log are in comments, but I can attest that they work. I've seen them all print their message at the console screen. In the enemy array, I put a prefab of my enemy. It's important to take this into account because the main problem is that Unity seems to detect the spawn thing (since the debug.log // Debug.Log("CurrentEnemyNumber >= AmountEnemyInWave : " + (CurrentEnemyNumber >= AmountEnemyInWave)); does show in console) But no physical enemy appears. Any clues, someone? This is a major issue for me. Thanks a lot!

Viewing all articles
Browse latest Browse all 122

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>