Create A 2D Idle Clicker Game in Unity! Tutorial 4 | Spawning Animals - androidgamestore.net

Create A 2D Idle Clicker Game in Unity! Tutorial 4 | Spawning Animals

TimmyJTech
Views: 239
Like: 15
Hey guys, what’s up! Tim Here!
Here is how we get animals spawning in once they have been rounded up! The health bar signifies how long until the animal is caught and then a new random animal replaces it! I hope you all enjoy it!

Find the Code on Github:

Please Like and Subscribe for more! 👍
Check out My Latest Video Here!

Unity:

Visual Studio Code:

▼ Follow Me
Instagram: TimmyJTech
Twitch:
Twitter:

▼ Help me out by joining my Patreon!

▼ Join my Discord Server!

🎧 Music 🎧
▼ Background Songs ▼
▼Title: [BLOSSOM.] (w sugi.wa)
Artist Name: KEEM.THE.CIPHER
Link:
▼Title: Evening Tide
Artist Name: Kupla
Link:
▼Title: [REVIVE.]
Artist Name: KEEM.THE.CIPHER
Link:
▼Title: within
Artist Name: leavv
Link:
▼Title: Moonlight
Artist Name: The Deli
Link:

▼ Outro Song ▼
Title: Infinite
Artist Name: Valence
Link:

#idleclickergame #unitytutorial #TimmyJTech

22 Comments

  1. not sure if you'll see this on such an old video, but i keep getting an error that type or namespace transform could not be found. I've tried a few things but i cant figure out what I'm doing wrong

  2. Im unable to get the button to work at all. My enemy doesn't react at all to being clicker no matter where it's at or if the game is running or not. Can someone help, please?

  3. 7:14 you secretly change from EnemyManager to AnimalManager….

  4. For anyone watching this, at 12:36 make sure you create the prefab in your assets and not in your Hierarchy and then drag and drop your different elements.

  5. hey man, im getting this error : 'GameObject' does not contain a definition for 'Length' and no accessible extension method 'Length' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)…. i've checked everything and is all correct, don't know what is wrong

  6. Hi Timmy, thanks for the tutorial. I have a problem, the new monster spawn outside of the canvas for some reason, I already double checked the code and it seems to be correct. Do you know why this happens ?

    edit: nvm I found out why, I didn't add the reference to the canvas on the monster manager

  7. I get errors but none of the ones you get. On the line you put public Animal curAnimal it just keeps saying Animal cannot be found

  8. Not sure if you're still responding to comments but after writing all of the EntityManager.cs file (I'm using Entity instead of Animal) I get a CS1061 error because the GameObject[] doesn't contain a definition for 'length'. This is weird because I made sure I wrote it exactly how you did but you didn't get this error, also I wrote it as an array so I don't know why it's having an issue with entityPrefabs.lengthI'll copy paste all my code below and here is the error exactly as written in Unity: 'GameObject[]' does not contain a definition for 'length' and no accessible extension method 'length' accepting a first argument of type 'GameObject[]' could be found (are you missing a using directive or an assembly reference?)CODE:using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class EntityManager : MonoBehaviour {

    public GameObject[] entityPrefabs;

    public Entity curEntity;

    public Transform canvas;

    public static EntityManager instance;

    void Awake() {
    instance = this;
    }

    //Spawn
    public void SpawnEntity() {
    GameObject entityToSpawn = entityPrefabs[Random.Range(0, entityPrefabs.length)];
    GameObject obj = Instantiate(entityToSpawn, canvas);

    curEntity = obj.GetComponent<Entity>();
    }

    //Replace
    public void ReplaceEntity(GameObject entity) {
    Destroy(entity);
    SpawnEntity();
    }
    }

  9. thank you for this tutorial , it helps me a lot!

  10. Hello, the animals seem to be appearing in random order. How can make it to cycle the list in an order?

  11. Somehow the Text doest work at all. The only Text i can drop into the GameManager Script is the GameObject – 3D Object – Text – Text Mesh Pro. That Text gets stuck behind the Background image. No idea how to fix any of this.

  12. I noticed when we created the 3 scripts before that we named one EnemyManager and then changed it to AnimalManager inside unityThis doesn’t actually change the name inside the script and therefore gave me errors while working on the AnimalManager script. I simply copied my code and recreated the AnimalManager script (with the correct name from the start)in unity then pasted my code in there and everything works fine now. If anyone else is having this problem with the AnimalManager Script just check the Public class name (next to MonoBehaviour) and if it still says EnemyManager then do what I did.

  13. My Prefabs are all on the screen at once not just one random one?

  14. My text isnt working or updating, @ 4:45 you did a jump cut and then it showed a '0' after the dollar sign. Im wondering what did you do to display this?

  15. Once again a great tutorial cannot wait to see more!

  16. Did you duplicate the Duck Prefab, then change the name and png? @12:32
    Also, my duck does not respawn when I 'caught' it.
    Also, Unity 2019 is pretty close, I just had to change the AnimalManager.AnimalPrefabs.size to 1 in the Inspector…
    Do I have to do this all over in Unity 2021, due to some compatibility error?

    I was able to follow you up until the duck not respawning, and not knowing if you duped the prefabs quickly, or if you crafted each one all over again from scratch.

  17. Ahah! I found an issue in my Unity interface, the "Animal Manager (Script)" has 3 Animal Prefabs. The first one, Element 0, gets deleted upon capturing the animal, then is displayed in the Unity interface as "missing". The animals rotate between the remaining 2 of 3 animals correctly. But I need to fix this bug first. Is there a reason it is deleting the Element 0 prefab and not allowing re-selection of it? It was added to the canvas, iirc.

    I was able to stop it from being "displayed" as missing, by adding it directly from the Prefabs folder to the Animal Manager (Script) of the Unity interface, but it is still acting the same way and Element 0 is never selected from the array for spawn again. hm

    For the time being, I am going to use a potentially bad technique, but simply adding two of the first animal to the array of animals, so that the animal can be spawned.

Leave a Reply

Your email address will not be published.