Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Official 2D Roguelike: Q&A

Discussion in 'Community Learning & Teaching' started by Matthew-Schell, Feb 10, 2015.

Thread Status:
Not open for further replies.
  1. Benarius

    Benarius

    Joined:
    Jun 11, 2015
    Posts:
    16
    Hooray...the weekend is here. After doing some research and even writing my first game in Unity (for PC and tablet) I will start with this tutorial again as I now can figure out lots of my own once I will get stuck. Lets see how we go this time. I am positive I make it all the way through. Looking so forward to.
     
  2. Enviy

    Enviy

    Joined:
    Jun 14, 2015
    Posts:
    1
    I've been following along with the tutorial videos but I'm completely stuck at the fifth video. I'm at the GameManager script step where the video shows an individual 'assigning' prefabs to the GameManager game object in the inspector view. I'm using Unity 5 and I don't have any of those fields. I have no idea what to do now because don't I need to assign the created prefabs to the scripts in the GameManager game object? I've been searching the forums and the youtube comments but so far no luck in finding a solution to the difference between the current version of Unity 5 and the version of Unity that was used in/for the video.

    Any help from anyone who's had similar issues would be much appreciated!
     
  3. Benarius

    Benarius

    Joined:
    Jun 11, 2015
    Posts:
    16
    Hi Enviy,

    I dont know how else to put it. I got stuck over and over. I realized this tutorial is too advanced and looked for simpler ones. I would advice to learn first the basics and then you will be able to figure it out the obstacles in the tutorials yourself. Because after handling this problem you certainly will run into the next. Most of the obstacles come from version differneces and some minor understandings of how Unity works. All I am saying is that was my conclusion, get into the basics and come back. The tutorial is tagged as intermediate. And to get to that level do about 50 hours beginners tutorials, and the right ones. Good luck.
     
  4. Audiclian

    Audiclian

    Joined:
    Jun 27, 2015
    Posts:
    1
    I believe I know what you're talking about. I had issues with it as well as I'm using Unity 5.1.1f1 and it doesn't look exactly the same as the video's version of Unity. Just for clarification, are you stuck around 1:40 in the video tutorial? If so, it's a quick fix to adjust. Please let me know what part of the video (min:sec) you're stuck on.
     
  5. MurDoK722

    MurDoK722

    Joined:
    Jun 9, 2015
    Posts:
    15

    playerFoodPoints start at 100. Also, Food text drops to 99 on move but it still prompts I survived day 1 and starved. I tried to add a Debug.Log to the Attempt Move and it showed an error on food--; directly below it but it simply prompted a compiler error until i deleted Debug.Log
     
  6. MurDoK722

    MurDoK722

    Joined:
    Jun 9, 2015
    Posts:
    15
    I am unsure if this has anything to do with it. But after I take a step and it says I only survived one day. I look under the Game Manager(clone) and the script becomes unchecked after i die, but the Player Food Points remain 100
     
  7. MurDoK722

    MurDoK722

    Joined:
    Jun 9, 2015
    Posts:
    15
    Okay Now I have finished all of the tutorials and added Mobile controls and Now my player won't move whatsoever. I have added the UNITY_EDITOR Code in and switched the build back and forth from standalone to IOS and still nothing...
     
  8. Dano13

    Dano13

    Joined:
    Jun 29, 2015
    Posts:
    4
    Hi there,

    I am hoping some kind soul can point me in the right direction here. I have been working through the Roguelike tutorial and everything has been working great until I hit step 12 (UI and Level Transition). As the first real test of the game - most stuff works but a bunch of stuff is broken. What is especially baffling is I copied and pasted the code directly from the web pages.

    So here are a couple of questions

    1) When I run the game the game progresses to Day 1, Day 2 and then jumps to Day 5 for some reason. At Day 5 all my food disappears. I wrote some debug code to try and figure out what is going on and on every level transition the GameManager runs the Awake function again and runs On LevelWasLoaded multiple times. Here is a print out of what is happening

    <<< Game Started
    Awake called
    <<<<< Next Map (Exit point hit)
    Awake
    OnLevelWasLoaded Called. Level=1
    OnLevelWasLoaded Called. Level=1
    <<<<< Next Map (Exit point hit)
    OnLevelWasLoaded Called. Level=1
    OnLevelWasLoaded Called. Level=2
    Awake
    OnLevelWasLoaded Called. Level=1
    OnLevelWasLoaded Called. Level=2
    OnLevelWasLoaded Called. Level=3
    Awake
    OnLevelWasLoaded Called. Level=1
    OnLevelWasLoaded Called. Level=2
    OnLevelWasLoaded Called. Level=3
    OnLevelWasLoaded Called. Level=4


    What the heck? OnLevelWasLoaded is an automatic function? How can it be called multiple times? Also, why is Awake called multiple times.

    Here is the actual code (Except I had to remove the completed namespace for some reason)

    https://unity3d.com/learn/tutorials/projects/2d-roguelike/ui-levels

    I know its crazy to expect someone to instantly debug this from this output, but does anyone have any tips on how to get to the root of this crazy problem?

    2) I have enemies inside the inner walls of the game. This is not supposed to happen is it?

    3) Is there an easy way to set up the completed assets into a full game so I can see if this weird behaviour is inherent in the game (I doubt it, but I would like to rule it out before I keep slamming my head against the wall).

    4) What is with the Completed namespace? Why is it there if the game editor makes me remove it?
    Oh - I am using Unit 4.6.
     
  9. Dano13

    Dano13

    Joined:
    Jun 29, 2015
    Posts:
    4
    I suspect there is something wrong with the code I pasted. In the code it says

    void Awake()
    {
    //Check if instance already exists
    if (instance == null)

    //if not, set instance to this
    instance = this;

    //If instance already exists and it's not this:
    else if (instance != this)

    //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
    Destroy(gameObject);

    //Sets this to not be destroyed when reloading scene
    DontDestroyOnLoad(gameObject);

    //Assign enemies to a new List of Enemy objects.
    enemies = new List<Enemy>();

    //Get a component reference to the attached BoardManager script
    boardScript = GetComponent<BoardManager>();

    //Call the InitGame function to initialize the first level
    InitGame();
    }

    But I ran debugging code, and even when the gameObject is destroyed the rest of the Awake function is called - so it is calling the InitGame as well as the DontDestroyOnLoad even though it shouldn't be. However I only ever see one instance of GameObject(clone) in the hierarchy - so I think it is eventually being destroyed but not before fundamentally wrecking the game.

    But this theory doesn't sit well with me. How can I be the only one to notice an inherent flaw in the program after all these years? So it likely isn't a flaw - but I have no idea what is going on. How can my version of Rogue be so broken even though I copied and pasted all of the code?

    Oh - one more thing - I put a Debug OnTriggerEnter2D on the player script - and for whatever reason, on the later levels it is firing multiple times. How can this be, unless there are multiple instances of the Player Script or something? Note - there is only one instance of Player in the Hierarchy.
     
    Last edited: Jun 30, 2015
  10. Cajued

    Cajued

    Joined:
    Jun 14, 2015
    Posts:
    3
    Hey Mr.Schell, geetings from Brazil! First, let me congratulate you for this very helpful tutorial and for all the attention you give to the people in the forum!
    I'm very new to programming but I already know the basics of certain languages and I'm acually focused on making 2d game right now. So, I made some sprites on my own and substituded some from the assets store. I'm in lesson 5 and when I run the game it shows this:


    I remade my steps and I'm pretty sure it's something to do with the sprites because I used the grid (32X32) option since the automatic was selecting the whole image as one sprite:


    If you could help me I would be very happy :D
    Stay awesome, Cajued.
     
    Matthew-Schell likes this.
  11. msbabybeast

    msbabybeast

    Joined:
    Jun 8, 2015
    Posts:
    4
    It turns out that I didn't set the sorting layer of Player, Enemy1, and Enemy2 to "Units." Thank you.
     
    Matthew-Schell likes this.
  12. msbabybeast

    msbabybeast

    Joined:
    Jun 8, 2015
    Posts:
    4
    Yeah, it was because of the sorting layers. Thank you.
     
    Matthew-Schell likes this.
  13. JymWythawhy

    JymWythawhy

    Joined:
    Jan 18, 2015
    Posts:
    25
    Cajued,

    The secret is in the "Pixels Per Unit" option you show in this screen shot. You should set that to 32 instead of 100, as the sprites are 32 by 32 instead of 100 by 100 pixels. That will cause Unity to make those sprites larger, and you wont have the shrunken sprites you saw.
     
    Matthew-Schell likes this.
  14. Cajued

    Cajued

    Joined:
    Jun 14, 2015
    Posts:
    3
    Can't thank you enough Jym!!
    Now it's working perfectly fine!!
     
  15. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    FYI the videos were done using Unity 5 so it shouldn't be significantly different. Please give as much info as you can and we'll try to help you.
     
  16. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    My pleasure, thanks for your kind words :) As Jym says, if you're adding new art, make sure pixels to units is set to 32x32.
     
  17. Dano13

    Dano13

    Joined:
    Jun 29, 2015
    Posts:
    4
    Well the weirdness I was experiencing wasn't in the Completed version, so it was something I mucked up. Also - for anyone interested the easiest way to load a Completed project version is to just go to the Completed Scene and double click it.

    So I had one version that didn't work and one that did. So I thought I would be clever and move the broken version into its own prefab folder called PrefabBroken, and then move the completed prefabs into the Prefabs folder and then slowly replace the completed prefabs with my broken ones and see at which point it broke.

    But this wasn't really achievable since it led to a mishmash of various assets pointing to different versions of scripts etc, and somehow in my process my broken assets started working - i.e. whatever was broken is lost now so I am not going to learn anything from this experience.

    So - I have two questions in an attempt to salvage something out of this frustration.

    1) When I placed breakpoints in mono, sometimes I would tell it to Step into (F11), but when it hit a line like Debug.Log("Blah") the line would just turn green and stay there until I hit F11 about a hundred times. Why is it doing that? How do I make it move to the next line like I am asking it to?

    2) So I did see a difference between my broken version and the completed version. The Board entity only existed once in the completed version, while the Board entity existed multiple times in my broken version - including multiple exits which was causing chaos - so something was being called multiple times and/or not being destroyed. Given such weirdness - if you were in this position - what strategy would you use to get to the bottom of such a mess?
     
  18. SDRX

    SDRX

    Joined:
    Jul 1, 2015
    Posts:
    2
    Hello there! Thank you very much for this great tutorial! Without this what I would like to it would be impossible for me, since I do not have much knowledge of programming ... I created my character, a few enemies, their animations and the environment and all this works well ... Before continue creating characters and improving the environment I made a homescreen with the well-known play button, when the scene containing the game is loading is loaded twice, I know that is something that affects boardmanager and the loader script but I'm a bit lost ... Any help? Thanks for your time!
     
  19. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    Sorry to hear you're having problems. The reason we have a completed namespace is so that we can include the completed scripts in the project folder and not have the class names conflict with the new scripts the person doing the tutorial is typing in. If you copy the scripts from the website and don't remove the completed namespace then you'd have two copies.

    If the steps are properly executed you should not experience problems, I've tested the project on my end without the errors you experience. My guess is that if you've copied the scripts you've missed a step in creating the game objects and prefabs.
     
  20. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    You might need to add a boolean to your button like isClicked and then check if it's true, to make sure you're not firing the event multiple times. That is assuming I understand your issue. Can you give more info about exactly what is going wrong?
     
    SDRX likes this.
  21. SDRX

    SDRX

    Joined:
    Jul 1, 2015
    Posts:
    2
    Thank you very much for your reply. Great, I'll see if I can add the boolean... And yes of course, I will try to explain better... Apologize, unfortunately I have not a very fluent English as I would like ... Ok, I have a main scene with play button to jump to the scene level1 where is the game ... when I click on the play button level 1 and 2 of the game are loaded at the same, in the game you can see the gameobjects of each level overlapping, also in the Hierarchy and the counter indicates that we are level 2 and not 1 where should I start ... I also created on the canvas one UIImagen for GameOver ... in this case we have a Quit button that works and one with the option to restart with the same problem loading the game again ... I attach some screen shots to try to explain better ... I can also host the project on my drive in case you want to download? Thanks again for your time and your support, cheers!

    Main Scene / Start Button
    Captura de pantalla 2015-07-02 a la(s) 19.41.54.png

    Scene Level1 / Game / Overlapping duplicate GameObjects on the Hierarchy
    Captura de pantalla 2015-07-02 a la(s) 19.42.37.png


    Scene Level1 / Game / Overlapping duplicate GameObjects on the Game
    Captura de pantalla 2015-07-02 a la(s) 19.31.46.png

    Best!
     
    peteorstrike likes this.
  22. asperw

    asperw

    Joined:
    Oct 19, 2012
    Posts:
    3
    Hi All,

    I've been following this tutorial for the past three days now, and got all the way to the end of step 11 where we get to really test our game, and I've got problems.

    I have the laziest characters. My Player only moves once. Then I guess he gives up because he won't move again. Ever. The enemies don't move once he's done either. I've tried setting the level to 1 so there's no enemies and he still only moves once.

    My game has a huge tear right through the center of the room, it is so ugly that I may weep. There are no strange X/Y translations on any objects or scripts.

    I've re-watched 1-11 twice (once on Unity website and on YouTube for good measure) just following along to make sure everything was perfect... and it is. It's perfect. But I'm still having these issues. I've read through YouTube comments, this forum, and Reddit trying to find the answers. I've refreshed my assets and quadruple checked all the layers and scripts and game objects. I've even checked in the project input settings for the raw axis input buttons, and sure enough, the buttons I am pressing are the right buttons.

    doingSetup is not in my scripts, so that can't be it. PlayersTurn and EnemiesMoving are true and false where they should be. I'm not using that namespace Completed thing that is in the Completed scripts. I don't have two gameManager scripts on my gameManager prefab (that was one person's problem). And as for the tear in my game, I am using free aspect on the game resolution setting (that fixed it for someone else)

    As you can see, I would like to play the game I have created thanks to this tutorial, but cannot.

    I am using OSX 10.10.4 Yosemite, and Unity 5.1.1f1. Both as up to date as they can be. Please send help.

    P.S. I have no console errors or warnings or whatever. The game is perfectly fine doing what its doing, which is making me very sad. :(
     
  23. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    Stupid question @Matthew Schell:
    In the BoardManager Script inside BoardSetup() ... why do we have to cast "as GameObject" here?
    Code (csharp):
    1. GameObject instance = Instantiate(toInstantiate, new Vector3(x,y,0f), Quaternion.identity) as GameObject;
     
  24. thepolycrafter

    thepolycrafter

    Joined:
    Jul 2, 2015
    Posts:
    3
    Hi, thanks for this neat tutorial! I am just starting out w 2D animation and learning about unity.

    I'm running into a silly problem in the second video. I've already figured out how to work around it, but its still driving me nuts.

    The problem is I never get the "Create New Animation" window after I drag and drop sprites into the 'Player' component.

    When I drag sprites to the player for the first time, the player controller gets created in Sprites folder, and an animation gets created with the name "Scavengers_Spritesheet_#".

    The real problem is I never get the chance to name animations, which starts getting really confusing when they all start with the same name. I'm working around it by going to Animation and creating clips (which gives me the chance to name them), but it would be nice to get the prompt like in the tutorial.

    I'm on unity 5.1.1 on Windows 8.1 . Tried creating different projects from scratch but the issue continues.

    Thanks in advance!
     
    Last edited: Jul 7, 2015
    Idji, Deleted User and JavadocMD like this.
  25. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    @thepolycrafter This has apparently been changed with Unity5.

    You can simply rename the animations yourself, though. If you do that you will just have to rename them in the Animator yourself as well. Though this is more for your own organization. The important thing is which animations are assigned to each node in Mecanim.

    If you want to name the animations yourself from the beginning, you have two more options:
    1. create an animation the way you create scripts. Name it - then drag the animation into your Animator and after that assign the frames manually in the Aniamtion window (Ctr-6).
    2. Select your character - open the animation (not the animator) window and under your rec, play, frame forward, frame backward buttons there's a dropdown which shows the current animation. There's also a "create new clip..."


    Ultimately all those things do the same. :)
     
    Matthew-Schell likes this.
  26. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Because...

    It's a C# thang.

    Due (iirc) to the strict typing rules of C# you need to cast the Object "toInstantiate" as a GameObject so C# understands what type of Object it is.

    This is not true for all languages, and in UnityScript (aka: JavaScript) this is not necessary.
     
    the_motionblur likes this.
  27. thepolycrafter

    thepolycrafter

    Joined:
    Jul 2, 2015
    Posts:
    3

    Thanks a bunch for the confirmation @the_motionblur ! Glad to know Im not going crazy and missing the window somewhere. I'll use the options you mentioned.
     
    Matthew-Schell likes this.
  28. MurDoK722

    MurDoK722

    Joined:
    Jun 9, 2015
    Posts:
    15
    Okay, I have finished all of the tutorials. I am in the midst of getting my unity controller up and running ( which is definitely a pain). However, On top of all of the issues I have been having. It now won't even let me play or control the Player. It starts up and everything seems to be working but my player will not move.
    I have already tried switching the build settings, and even applied a Unity editor code so that it might let me control and test the game. Still nothing, and all of these issues aren't pushing me away from game design, but are very frustrating.
     
  29. z3r0shade

    z3r0shade

    Joined:
    Jul 9, 2015
    Posts:
    1
    Hello! This tutorial was great for learning the ropes of setting stuff up. I just had a quick question:

    When moving player around he occasionally wobbles off the straight line and ends up partially in squares rather than entirely in squares such that he can end up halfway inside a wall. Even worse, depending on my movement I can end up with a player and enemy sharing a square somehow or even two enemies sharing a square when they try to follow me.

    This seems to happen if an enemy moves on their turn while the movement coroutine is running for moving the player into that same square and then I get stuck.

    | |e|x|
    | | |p|

    If "e" is an enemy and "p" is the player, when I hit "up" and move into the square "x", if the enemy was supposed to move that turn he also moves into the square and i get stuck. I can get both issues to happen even when I open the "Main" scene from the completed folder, I think it may be an issue with the tutorial and code itself since I can reproduce it with the "completed" stuff but it may be just something silly I'm doing. I'm not sure. Any Help?
     
  30. Douglas1701

    Douglas1701

    Joined:
    Jul 7, 2015
    Posts:
    3
    Hello, I am having an issue with my Board Manage script. When i try to run it i come up with 4 errors i seem to not be able to figure out. The main one says that The namespace Complete already contains a definition for "Board Manage". I check my script and it seems to be accurate to the tutorial but maybe a second pair of eyes need to look at it. I tried copying and pasting the script on the tutroial videos and the errors still show up.

    Any help would be greatly appreciated, below is a screen shots of the errors

    upload_2015-7-10_0-39-38.png
     
  31. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    I've worked through the tutorial now and would like to give some feedback (@Adam Buckner @Mike Geig and @Matthew Schell)

    To make this clear before I write anything: I love the Unity learning materials. There is so much to learn and it's ever growing. The work and free access is really appreciated and I think sets Unity apart from many other programs or companies (Allegorithmic being another one of the really good ones on that field). You guys are all doing an excellent job.

    So the things I really loved aboout the Roguelike training series:
    • There are a lot of advanced techniques not usually taught in training series. Please more of that even if it makes my head hurt at times ;)
    • A roguelike is a topic that is not usually taught so it is also very welcome to see other things than the usual beginners projects. Maybe RPG like elements and project organization would also be interesting in the future.
    • The scope of the project seems just right to learn new and deeper concepts without being too much.
    • The visual explanations are also really helpful to understand what's going on.

    What I didn't like about it, though:
    • It's too fast. Even for pausing and rewatching it's really way too fast. Looking at code being typed while the explanation is given creates a little mental conflict in whether to read or to listen and understand for me. Especially since the training videos have most of the natural pauses in speech edited out so it hammers information even faster.
    • Sometimes some explanations are being said while a different line of code is already being written - which is even more confusing. Rewinding, relistening and rewatching several times feels as draining as re-reading a paragraph in abook over and over again.
    • Sometimes I feel that the video should show more often what we've just implemented into the game in smaller steps. Some videos go a very long stretch to implement new features where it is not always easy to keep track what will have which effect in the game later on. Maybe that is just my way of working but I rather try smaller steps and see whether what i've just implemented does something. Iterating and improving functions takes more time to explain but it could also make it more obvious what part of a function is the core and what is added for improvement (beyond the bare function).
    • This one I feel could be very important: It would be really beneficial for the training to take maybe an extra video before a long complex new script (like the MovingObjects script for example) that takes the time to explain what is going to be scripted any why. Maybe even visually. Sort of like the explanaition for the Board setup with the tile numbers.
      Reading the code is all good and important but for the designer of the code it's logical why a function is written that way and which one will be next and coming up to be used in conjunction. For people unfamiliar with the project I find it super difficult to follow when I don't know why a function is being written for which purpose and what the goal design will look like.
      It's sort of like cross reading a book or the paragraphs or table of contents before reading a book. When the brain already has an idea of the design for what's to come (and why) it can process the information much better.

    Anyway. These are my 2 cents. Maybe some people agree on some of the points. And as I said - I really love what Unity are doing with the learn section.

    I really feel like I've learned a lot of advanced and very important concepts about code design. I don't think I understood everything but then again: I'm an artist. not a coder. That's what I keep telling myself :D
    Please keep up the good work. Looking forward to a lot of more training to come :)
     
  32. DanarKayfi

    DanarKayfi

    Joined:
    Aug 27, 2012
    Posts:
    72
    Hi Mat, Have you noticed on mobile when you swipe the character move like 1.5 square and goback like shake move?
     
  33. Krystman

    Krystman

    Joined:
    May 19, 2014
    Posts:
    5
    Currently following this. I generally like this a lot. It seems like a much more reasonable game to work with than most of the other tutorials I found.

    However, I think step 6 & 7 are really problematic. I understand that the goal here was to teach inheritance. But especially in step 6 the tutorial just dumps a lot of really daunting concepts without explaining them or showing how they will work. We not only have abstract classes, but virtual methods, IEnumerators, Coroutines. I've been programming and teaching games for years and even I had to look some of this stuff up. What's worse is that instead of closing the arc and showing why it was useful, the next step (7) is going straight into destructible walls. At this point we haven't even moved a single object. That's simply not how you write a game and it is likely to overwhelm a lot of readers.

    I feel it would be useful to add a step 6.5 where we get an object moving by inheriting from MovingObject first before moving on to more complex stuff. It would be perhaps even better to slow down at 6. For example, you could leave collision detection out of the picture at first and add that functionality step by step. I feel this would not only help understanding but also teach the practice of iterative compartmentalization that is so vital in game development.
     
    the_motionblur likes this.
  34. Akshat_Malik

    Akshat_Malik

    Joined:
    May 23, 2015
    Posts:
    16
    Hello Everyone,
    I am encountering a very strange problem. I am really unable to realise what might have cause it. What happening is that when I move my player, it isn't moving. It is rather moving really slowly. And that to in any direction. Same goes with the enemy.
     
  35. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    In that case you know at least that the error will be in the MoveableObject script as both player and enemy derive from it.
    Start looking for errors around the methods that take care of movement speed and direction.
     
  36. Akshat_Malik

    Akshat_Malik

    Joined:
    May 23, 2015
    Posts:
    16
    Thanks, I'll look into it and let you know.
     
  37. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    Can you post the code of the script that launches the main scene? My best guess is that that is somehow causing the scene to be loaded twice. Love the new pixel art! Very nice!
     
  38. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238

    The issue is that you have two copies of the BoardManager script in your project. If you are copying and pasting from the website move the scripts in the completed folder out of the project folder temporarily.
     
  39. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    Thanks for your feedback! I got a lot of notes that it was fast from others so I'll keep that in mind going forward. I was just a little worried about it being too long. Originally I was hoping for it to be much shorter :)

    One of my upcoming projects is to write a text guide to accompany it that will hopefully make it easier for people to go back and review without scrubbing the video, still thinking about the best format for that.
     
  40. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    Can you confirm that your rigidbody is set to isKinematic = true? That's my guess about what's going wrong there.
     
  41. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You can also use the webplayer templates folder:
    http://theantranch.com/blog/avoid-compilation-with-webplayer-templates/
     
  42. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    Thanks for your feedback Krystman.
     
  43. Dchand4

    Dchand4

    Joined:
    Jul 11, 2015
    Posts:
    3
    HI, I've got another error in MovingObject. I'm using unity 5.1.1. I finished the script and I can't seem to find what's the matter. The errors are:
    (33,18): error CS1525: Unexpected symbol `if'
    (39,30): error CS1519: Unexpected symbol `return' in class, struct, or interface member declaration
    (42,31): error CS0116: A namespace can only contain types and namespace declarations
    (55,40): error CS0116: A namespace can only contain types and namespace declarations
    (70,37): error CS0116: A namespace can only contain types and namespace declarations
    (73,1): error CS8025: Parsing error
    My script is here:
    using UnityEngine;
    using System.Collections;

    public abstract class MovingObject : MonoBehaviour {

    public float moveTime = .1f;
    public LayerMask blockingLayer;


    private BoxCollider2D boxCollider;
    private Rigidbody2D rb2D;
    private float inverseMoveTime;


    // Use this for initialization
    protected virtual void Start ()
    {
    boxCollider = GetComponent<BoxCollider2D>();
    rb2D = GetComponent<Rigidbody2D>();
    inverseMoveTime = 1f / moveTime;

    }

    protected bool Move (int xDir, int yDir, out RaycastHit2D hit)
    {
    Vector2 start = transform.position;
    Vector2 end = start + new Vector2 (xDir, yDir);

    boxCollider.enabled = false;
    hit = Physics2D.Linecast (start, end, blockingLayer);
    boxCollider.enabled = true

    if (hit.transform == null)
    {
    StartCoroutine(SmoothMovement (end));
    return true;
    }

    return false;
    }

    protected IEnumerator SmoothMovement (Vector3 end)
    {
    float sqrRemainingDistance = (transform.position - end).sqrMagnitude;

    while (sqrRemainingDistance > float.Epsilon)
    {
    Vector3 newPosition = Vector3.MoveTowards (rb2D.position, end, inverseMoveTime * Time.deltaTime);
    rb2D.MovePosition (newPosition);
    sqrRemainingDistance = (transform.position - end).sqrMagnitude;
    yield return null;
    }
    }

    protected virtual void AttemptMove <T> (int xDir, int yDir)
    where T : Component
    {
    RaycastHit2D hit;
    bool canMove = Move (xDir, yDir, out hit);

    if (hit.transform == null)
    return;

    T hitComponent = hit.transform.GetComponent<T>();

    if (!canMove && hitComponent != null)
    OnCantMove(hitComponent);
    }

    protected abstract void OnCantMove <T> (T component)
    where T : Component;

    }

    Thanks!
    -Dylan
    (By the way, the tutorials are really good!)
     
  44. Shunaev

    Shunaev

    Joined:
    Mar 4, 2015
    Posts:
    9
    Hi, I noticed the same bug, isKinematic is set to true. By the way, thank you for your work!
     
  45. DarthStevenus

    DarthStevenus

    Joined:
    Jul 19, 2015
    Posts:
    2
    I've been going through this tutorial series and I'm stuck on part 5, writing the GameManager script. I've gotten to the part at 2:56 when he tests the BoardManager and GameManager scripts. As far as I can tell my scripts are the same as his, I have no compiler errors, but whenever I hit play to try and test the GameManager, Unity freezes and I have to close it from the task manager. I'm on Windows 7, using Unity 5.1. Here are my scripts:

    GameManager:

    using UnityEngine;
    using System.Collections;

    public class GameManager : MonoBehaviour {

    public BoardManager boardScript;
    private int level = 3;

    void Awake() {
    boardScript = GetComponent<BoardManager> ();
    InitGame ();
    }

    void InitGame() {
    boardScript.SetupScene (level);
    }
    }



    BoardManager:

    using UnityEngine;
    using System;
    using System.Collections.Generic;
    using Random = UnityEngine.Random;

    public class BoardManager : MonoBehaviour {
    [Serializable]
    public class Count {
    public int minimum;
    public int maximum;

    public Count(int min, int max) {
    minimum = min;
    maximum = max;
    }
    }

    public int columns = 8;
    public int rows = 8;
    public Count wallCount = new Count(5,9);
    public Count foodCount = new Count(1,5);
    public GameObject exit;
    public GameObject[] floorTiles;
    public GameObject[] wallTiles;
    public GameObject[] foodTiles;
    public GameObject[] enemyTiles;
    public GameObject[] outerWallTiles;

    private Transform boardHolder;
    private List<Vector3> gridPositions = new List<Vector3>();

    void InitializeList (){
    gridPositions.Clear ();

    for (int x = 1; x < columns - 1; x++) {
    for (int y = 1; x < rows - 1; y++) {
    gridPositions.Add(new Vector3(x, y, 0f));
    }
    }
    }

    void BoardSetup() {
    boardHolder = new GameObject ("Board").transform;

    for (int x = -1; x < columns + 1; x++) {
    for (int y = -1; x < rows + 1; y++) {
    GameObject toInstantiate = floorTiles[Random.Range(0, floorTiles.Length)];

    if(x == -1 || x == columns || y == -1 || y == rows) {
    toInstantiate = outerWallTiles[Random.Range (0, outerWallTiles.Length)];

    GameObject instance = Instantiate(toInstantiate, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
    instance.transform.SetParent(boardHolder);
    }
    }
    }
    }

    Vector3 RandomPosition() {
    int randomIndex = Random.Range(0, gridPositions.Count);
    Vector3 randomPosition = gridPositions[randomIndex];
    gridPositions.RemoveAt (randomIndex);
    return randomPosition;
    }

    void LayoutObjectAtRandom(GameObject[] tileArray, int minimum, int maximum) {
    int objectCount = Random.Range (minimum, maximum + 1);
    for(int i = 0; i < objectCount; i++) {
    Vector3 randomPosition = RandomPosition();
    GameObject tileChoice = tileArray[Random.Range (0, tileArray.Length)];
    Instantiate (tileChoice, randomPosition, Quaternion.identity);
    }
    }

    public void SetupScene(int level) {
    BoardSetup ();
    InitializeList ();
    LayoutObjectAtRandom (wallTiles, wallCount.minimum, wallCount.maximum);
    LayoutObjectAtRandom (foodTiles, foodCount.minimum, foodCount.maximum);
    int enemyCount = (int)Mathf.Log (level, 2f);
    LayoutObjectAtRandom (enemyTiles, enemyCount, enemyCount);
    Instantiate (exit, new Vector3 (columns - 1, rows - 1, 0f), Quaternion.identity);
    }
    }
     
  46. grappler

    grappler

    Joined:
    Jun 26, 2015
    Posts:
    13
    I'm new to Unity so it threw me when I started trying to customize this tutorial and found that changing integer variables in the player script had no effect (e.g., wallDamage). I did figure out that it's because the player is already added to the hierarchy and therefore not being instantiated again from the edited script. Now that I know this, how do I efficiently update objects already in the hierarchy? I tried deleting the player object from the hierarchy and adding it back, but the player wouldn't move after I did that. Do I go to the prefab and choose "Refresh" or "Reimport"?
     
  47. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    Since it's divided up into chapters and (fortunately) the age of video bandwidth restrictions is long gone I wouldn't see longer training sessions as a problem. Everybody can go at their own pace. And ultimately if things are too condensed they have to be worked through over and over again to be understood anyways. So unless the viewer knows the ideas used in the training already it's not really shorter in the long run.

    For example - with the abstracs classes and functions etc. I frequently had to pause and google what these things actually do. Sure - you do explain it - but the abridged version that makes sense to someone who is used to working with it. I also have read "Head First Java" a few years ago so the idea of an abstract class and an interface was at least still a blurry concept in the back of my head somewhere.

    Still: Ultimately the board manager video took me roughly 3 hours to follow along, look up things and still trying to understand it better. The moveable object classes took me something around 4- 5 hours. Each on its owhn day since I cannot understand AND remember so many new things in one day.

    Soat least for me - a little slower with a little more explanation of the concepts would be super.
    Paired with more often going back to Unity to show what the current implementation does - perfect. :)

    Ultimately it's an advanced topic and as such its's absolutely okay. I know going into this that there will be concepts I don't know about. But I think if it takes up more time to digest or is divided up into smaller segments there's no harm for people new to the concepts. I know everybody has their own speed and things they know or don't know.
    So again that's just my 2 cents (and I do teach myself - so I can relate). :)

    An accompanying written script also sounds like a very cool addition. I'm really looking forward to all the upcoming things.
     
  48. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    If you are talking about public values then you can (and should) change them in the inspector. That's the hughe advantage of Unity: You can change them in the inspector. Values set in the inspector overrider the default set values from the script unless you set them back to default.

    If you are talking about private variables - they should have an effect immediately. No need to delete anything. just wait for the compiler to be finished. If it doesn't work there's an error in your script somewhere.

    If you don't understand what I've just written then please start with more basic concept tutorials for Unity before jumping into advanced topics. :)
     
  49. cyfrostan

    cyfrostan

    Joined:
    Jul 14, 2015
    Posts:
    3
    I've actually encountered minor, tho potentially very annoying problem as early as in part 2.
    Namely when I click and drag the sprites onto the play object I'm not prompted to name and save the animation, instead both the animation controller and the animation itself are automatically created in the sprite folder under default names ("Scavengers_Sprite_Sheet_" for animation and "Player" for the controller). I'm trying to find ways to rename them in editor, if I go outside the editor and rename the files it messes with the animation (makes it effectively invisible) and that approach is inefficient anyway since you have to manually rename 2 files per animation.
     
    Last edited: Jul 19, 2015
  50. cyfrostan

    cyfrostan

    Joined:
    Jul 14, 2015
    Posts:
    3
    PS Ok, I tried renaming them manually (aka in the file explorer) again and this time it worked, 3rd time's the charm I guess, but it's still woefully inefficient way of doing things.

    The most efficient way I've been able to figure out was to: select the desired frames from the sprite sheet, right click -> create -> animation (it let's you rename it as you do it), check the "Loop Time Box" in the animation, click and drag animation onto the player object (this doesn't create the sprite renderer), in the player object add component -> sprite renderer, click and drag the animation and its controller into their respective assets folders.
    Some of these steps can be done out of order.

    If there's a better way (or a way to fix the lack of prompt), I'd like to know.
     
Thread Status:
Not open for further replies.