2D Roguelike 5 of 14 : Game Manager

23
1



* IMPORTANT – This projects requires Unity 4.6 or greater *
Watch on Unity’s learn site here –

This 2D Roguelike project guides you through creating a turn based, tile based game with procedurally generated levels. In the game you play as a lone man trying to find food and survive the waste land for as long as you can.

This is part 5 of 14 in which we write our game manager script which uses a singleton pattern.

Presented by –
Matt Schell – Screencaster (@mattmirrorfish)

Help us caption & translate this video!

Nguồn: https://campaignforcivilrights.org/

Xem thêm bài viết khác: https://campaignforcivilrights.org/game/

23 COMMENTS

  1. If ur having issues at the start dragging GameManager and BoardManager make sure ur scrips read correctly. Mine said "public class NewBehavior : MonoBehaviour" it was supposed to read: "public class GameManager : MonoBehaviour".

  2. I got mine to work but I don't understand how Destroy(gameObject) works, wouldn't you have to Destroy(GameManager) if instance was null? I don't understand how that destroys the correct game manager if it isn't either the name of the object, nor the general object class?

  3. At 3:00 , when testing my application, my system memory shoots through the roof and Unity doesn't load the scene.

  4. I have errors, the first 1 is that it couldn't find the namespace BoardManager, the second is that the public Count needs a return

  5. After following this tutorial and coding for like 2-3 hours, it all fell apart at this point using the newest version of unity. At 3:00 Unity just pops up with an assload of errors, I even tried to copy and paste the provided coding (which caused more errors than the one I wrote.) They almost all say "Type 'BoardManager' already defines member called 'whateverthehell' with the same parameter types." This happens with 'InitialiseList', 'BoardSetup', 'RandomPositions', 'LayoutObjectAtRandom', 'SetupScene' and there's a couple other errors.

  6. I dont know what to do the level just wont generate at all not even the floor I did everything same as him and checked it like 5 times IDk whats wrong 3:00

  7. I don't understand the purpose of DontDestroyOnLoad function here. It is supposed to prevent the destruction of the game Object this component is attached to when loading new scene. But is not "Main" (I called it like this) the only Scene in the project ?

  8. "The type or namespace name 'BoardManager' could not be found (are you missing a using directive or an assembly reference?)"
    How to fix this error??

  9. And I have this problem
    NullReferenceException: Object reference not set to an instance of an object

    GameManager.InitGame () (at Assets/Scripts/GameManager.cs:20)

    Can anyone help me? I'm a noob in Unity, using Unity 2018.4.4f1. Nothing renders on screen. I have went through the tutorial many times, not sure whats up? can anyone help?

  10. I get the problem, that the board is 6×6 and not 8×8 and the exit is not connected to the board. Help me pls :/

  11. Could someone kindly explain me why is it necessary to translate the camera to (3.5, 3.5)? Or, actually more importantly, how do i determine how much should i translate it at all.

    Thank you! Looking the level appearing when hitting play was amazing, i'm so happy!

  12. so after 5 hours of work, i exited out of unity to take a break, and yes I did save. When I got back, for some reason the completed game files and mine had gotten combined and i had to delete it all and restart, RIP. ill go for something more basic i guess…

  13. The score doesnt reset when i game over and restart, it does not dubble up however, it just keeps counting?

  14. Never would've thought of having the initial (lightweight) Loader function in the MainCamera. That's a neat little trick that solves a key problem of a lot of Unity Singleton implementations – programmers/devs forgetting to add the GameManager prefab into the initial scene.

  15. Okay, so I've been reading through the comments before I made my own. On
    one side, you have the people who know what they're doing and they say
    this tutorial is fine.
    On the other side, you have people who have very little knowledge of
    coding and are extremely aggravated.

    I am not an expert and hardly experienced with coding of any kind. My
    issue is not with the coding, at least not directly. My issue with this
    tutorial is that even after I have done everything per his explanation
    (which I find to be quite good – take that for what you will), my program is not rendering. I hit the
    play button and nothing happens.
    Being new, I shrugged it off and decided to replace this portion with
    the presets, the ones that are supposed to be a model of what you need
    to have. Didn't work either. So, I used the preset scripts with the
    preset prefabs, thinking that maybe I had picked wrong layers or
    something (which I do understand, having done a little bit of graphics) –
    still no luck.

    After running the program as written and having it not work: I ran
    through a few debugging trials and tutorials, fixed the errors that
    appeared until everything was happy. Still was not rendering. Everything
    up until I hit the play button is working just as in the video. This
    includes seeing the drop downs and being able to put in all the prefabs
    and everything. No errors, no nothing, it just won't load my map.

    At this point, I'm not sure what's going on. Not being good with code or
    being 100% sure of what's going on (inexperience), I can't say one way
    or another why this isn't working. What I do know is that even the
    provided materials are not producing the expected or intended results.

LEAVE A REPLY

Please enter your comment!
Please enter your name here