Ask coding questions

← Back to all posts
Tower Defense finished
Bunnytoes (113)

@Coder100 @ANDREWVOSS I finished my td pog, I made a work around from the error, but now I need to export it to replit, how can I do it, I have to export the whole project not jest some scenes

Comments
hotnewtop
Bunnytoes (113)

@Coder100 so export it with webgl?

Bunnytoes (113)

@Coder100 got it, but I downloaded the webgl but it won't let me build and it says no webgl module loadeed

Coder100 (18089)

yeah you have to close it and open it back again @Bunnytoes

Coder100 (18089)

i think the video covered that? @Bunnytoes

Bunnytoes (113)

@Coder100 what do you use to export it the tutorial says inno but I am worried that it costs money

Coder100 (18089)

well
i didn't pay any money

@Bunnytoes

Coder100 (18089)

you can pay money to remove the unity splash screen sure @Bunnytoes

Bunnytoes (113)

@Coder100 thanks but one more thing, I need help ending the game when the when all enemies are dead here's the script

using System.Collections;
using UnityEngine;
using UnityEngine.UI;


public class WaveSpawner : MonoBehaviour
{
    public static int EnemiesAlive;


    public Wave[] waves;
    public Transform SpawnPoint;



    public float TimeBetweenWaves = 7f;
    private float countdown = 3f;

    public Text waveCountdownText;

    public GameManager gameMaster;


    private int WaveIndex = 0;


    void Start ()
    {
        EnemiesAlive = 1;
    }


    void Update()
    {
        if (EnemiesAlive > 0)
        {
            return;
        }

        
        if (EnemiesAlive == 0)
        {
            gameMaster.WinLevel();
            this.enabled = false;
        }


        if (countdown <= 0f)
        {
            StartCoroutine(SpawnWave());

            countdown = TimeBetweenWaves;
            return;
        }

        countdown -= Time.deltaTime;

        countdown = Mathf.Clamp(countdown, 0f, Mathf.Infinity);

        waveCountdownText.text = string.Format("{0:00.00}", countdown);






    }

    IEnumerator SpawnWave()
    {
        
        PlayerStats.Rounds++;

        Wave wave = waves[WaveIndex];

        EnemiesAlive = wave.count;

        for (int i = 0; i < wave.count; i++)
        {
            SpawnEnemy(wave.enemy);
        
            yield return new WaitForSeconds(1f / wave.rate);
        }
        WaveIndex++;

    }
    
    void SpawnEnemy(GameObject enemy)
    {

        Instantiate(enemy, SpawnPoint.position, SpawnPoint.rotation);
        




    }

    


}
Bunnytoes (113)

@Coder100 I know, I need help getting my game won to show when all enemies are killed

Coder100 (18089)

so

if (enemiesAlive < 1) { ... show next scene ... } @Bunnytoes

Coder100 (18089)

well
what is in WinLevel? @Bunnytoes

Bunnytoes (113)

@Coder100

public void WinLevel ()
    {
        GameIsOver = true;
        completeLevelUI.SetActive(true);
        
    }

the whole script is

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour
{
    public static bool GameIsOver = false;

    

    public GameObject gameOverUI;

    public GameObject completeLevelUI;

    
    
   void Start ()
    {
        GameIsOver = false;
    }

    // Update is called once per frame
    void Update()
    {
            

        if (GameIsOver)
            return;

       

        if (PlayerStats.Lives <= 0)
        {
            EndGame();
        }
    }

    void EndGame ()
    {
        GameIsOver = true;

        gameOverUI.SetActive(true);
    }

    public void WinLevel ()
    {
        GameIsOver = true;
        completeLevelUI.SetActive(true);
        
    }
}
Coder100 (18089)

strange... it should be set active

can i see your UI list @Bunnytoes

Coder100 (18089)

strange, what isn't working?
make sure you haven't set all the child elements inactive too

@Bunnytoes

these shouldn't be set active purposely.

Bunnytoes (113)

@Coder100 all the buttons are hooked up and stuff but when all enemies die it won't show this screen

Coder100 (18089)

@Bunnytoes hmm

so all the child elements are not disabled?

Coder100 (18089)

just make sure when you actually enable the element in the editor, you can see the UI @Bunnytoes

Bunnytoes (113)

@Coder100 they are disabled, disabling the main thing disable or enables them all, also changing enemies alive to waves.legth doesn't work

Bunnytoes (113)

@Coder100 do you know what I can do?

Coder100 (18089)

https://www.youtube.com/watch?v=7nxKAtxGSn8

are you following a tutorial? this should be included.