Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

So, to summarize, i make a empty game object called score and i create a function that adds a certain number for when a the enemy is destroyed?

Also, How would i make an if statement to check if my enemy gameobject is destroyed?

Usually destroying an object will set it to "null", so you can just check if the object is "null":

if (Enemy == null)

OH. MY. GOD. Thank you so much i needed that one line for like forever. now i can probably even make a level system!

Thaeres one problem tho, I did the code correctly, but it isnt working for the score count! heres my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Score : MonoBehaviour
{
    public Text scoreDisplay;
    public int score = 0;
    public Enemy Enemy;
    // Update is called once per frame
    void Update()
    {
        scoreDisplay.text = "SCORE:" + score;
    }
    public void IncreaseScore()
    {
        if(Enemy == null) ;
        {
            score += 1;
        }
    }
}

Hmm, what is calling the function "IncreaseScore"? Is this script attached to an enemy that has a call to it on its death?

wELP Im stupid.

NO! You are NOT stupid.

This is an extremely common mistake. It's one you will probably make at least once on every project (multiple times for larger projects). Everyone does. It's one of many simple errors you learn to look for first so you can fix it before tweaking your code.

If you only take one thing from this experience, I want it to be learning to not get down on yourself for making simple errors and mistakes; they aren't character flaws, they're just a part of the task. NO ONE writes perfect code the first time, every coder uses a debugger.

Thanks so much dude. I just finished the game and i think it was pretty good! if you want you can play it and thanks for ALL the help! Im currently working on my next Shooty Block and if i ever need help i know i can count on ya.

I'd love to see it, is it on your page?
Feel free to ask me questions anytime, I'm here to help.! =)

https://devv-logg.itch.io/shooty-block It has a boss and some music now!

Deleted 3 years ago

But, Im also having some trouble with feedback and views. Im gonna post it on different websites, But other than that, What should i do for feedback?

Also, Im having a MAJOR problem where when i make a refrence to other scripts from (example) my enemy script, and i make it public, I cant drag in the script at all! It doesent let me pick any scripts at all. Know any fixes?

Hey uh quick question. I dont know if your very fluent on the topic but im trying to make a little console to put my games on

Any kits or ideas?