Search Unity

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. pvqr

    pvqr

    Joined:
    Apr 27, 2015
    Posts:
    38
    Check in your GameManager and Player prefabs if there is nothing overriding your player's health (food points) and setting it to 1 or 0.
    If you are sure your health number is correct, try commenting the line
    Code (csharp):
    1.  food--;
    and see if you can walk normally.

    Do you have your food points displayed at the game screen? If so, change that line to
    Code (csharp):
    1.  food++;
    Is it incrementing correctly? Your health goes to 101 or 1 in the first step?
     
  2. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Don't forget, the project should include a finished or "done" example of the project, and each page should have the final code for that episode posted on the lesson page - so you can compare your code with the code from the finished project to track down any differences.
     
  3. MurDoK722

    MurDoK722

    Joined:
    Jun 9, 2015
    Posts:
    15
    Pirizao:
    Are you willing to get on TeamViewer with me and maybe check my code, prefabs, etc....

    Adam Buckner:
    I know that there are completed lines of code but I am really not sure what I am looking for.
     
  4. MurDoK722

    MurDoK722

    Joined:
    Jun 9, 2015
    Posts:
    15
    Also, I am not sure if it has anything to do with it, but this problem arose after I completed the Audio portion of the tutorial. Before that however, I had issues with the Exit not working which was never resolved.
     
  5. unscrypted

    unscrypted

    Joined:
    Jun 11, 2015
    Posts:
    1
    I was wondering how to modify the game to allow for diagonal movement? Can anyone help? Thanks!
     
  6. Benarius

    Benarius

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

    already in Part 2, when draging the idle sprites onto \player, no Save window pops up...please help. Installed the latest version yesterday.

    Thx

    Benarius
     
  7. RetroGamer28

    RetroGamer28

    Joined:
    Apr 28, 2015
    Posts:
    7
    Thank you for showing how to format my post. However, this still doesn't answer my question and I would like for someone to please help me with this problem. It seems no matter what I was told to do to fix this the problem still continues.
     
  8. NewPath

    NewPath

    Joined:
    Jun 11, 2015
    Posts:
    9
    @Matthew Schell , thanks for taking the time to make this tutorial, I picked up some interesting tips from it. I am a bit amazed at some of the comments from some people, and how they expect to get into game development without learning the language. In contrary to some, I appreciate you NOT taking the time out to explain basic programming concepts, as these tutorials should be about Unity, not C# or general object oriented design.

    Anyway, I saw a few repeated questions about the validity of some of your micro-optimizations. I'm not sure why one wouldn't simply test for themselves rather than ask, but regardless, I thought I'd do a couple of quick pseudo-benchmarks for demonstration and in doing so had an interesting result on one that I'm curious about.

    First, with regards to multiplication vs. division - this is an old-school optimization that's relatively language agnostic. Programmers should in general favor multiplication when they can. It's worth noting that most modern compilers will optimize this anyway, however. In C++, for example, the -ffast-math optimization includes -freciprocal-math which does this very thing. Based on these results, it looks like the C# compiler does something similar as well (on my platform).

    Consider the following code:

    Code (csharp):
    1.  
    2. static void Main(string[] args)
    3. {
    4. var timer = new Stopwatch();
    5.  
    6. float moveTime = 0.1f;
    7. float deltaTime = 0.0167f;
    8.  
    9. timer.Start();
    10.  
    11. for (int i = 0; i < 1000000000; ++i)
    12. {
    13. var distanceDelta = moveTime / deltaTime;
    14. }
    15.  
    16. timer.Stop();
    17.  
    18. Console.WriteLine("Time using division: {0}", timer.Elapsed);
    19.  
    20. timer.Reset();
    21.  
    22. float inverse = 1 / moveTime;
    23.  
    24. timer.Start();
    25.  
    26. for (int i = 0; i < 1000000000; ++i)
    27. {
    28. var distanceDelta = inverse * deltaTime;
    29. }
    30.  
    31. timer.Stop();
    32.  
    33. Console.WriteLine("Time using multiplication: {0}", timer.Elapsed);
    34. Console.ReadLine();
    35. }
    36.  

    On VS2013's compiler, on an Intel i5, I get the following output for a debug build:

    Code (csharp):
    1.  
    2. Time using division: 00:00:06.2162100
    3. Time using multiplication: 00:00:02.3945799
    4.  
    So division is about 3x slower than multiplication. Ah, but what happens when we let the optimizer do its thing? Here is the output from an optimized release build:

    Code (csharp):
    1.  
    2. Time using division: 00:00:00.2876348
    3. Time using multiplication: 00:00:00.2870048
    4.  
    It looks to me as though the optimizer has converted the division operation to a reciprocal multiplication. I didn't have the time, but looking at the code in the IDL viewer might confirm this. I'm certainly not suggesting leaving this optimization out of the code, since these results will vary by processor/compiler/platform. It does bring up an interesting point though - the profiler runs against an instrumented debug build, so it can potentially show operations like this as being statistically significant, when in fact that could get optimized away in a release build.

    I digress. More interesting to me is the magnitude vs sqrMagnitude, and perhaps what I'm experiencing is highly processor/compiler specific, but I got some interesting results. I certainly understand in theory why sqrMagnitude should be measurably faster, but... consider the following code:

    Code (csharp):
    1.  
    2. static void Main(string[] args)
    3. {
    4. var timer = new Stopwatch();
    5. var rand = new System.Random();
    6.  
    7. var start = new Vector3(rand.Next(), rand.Next(), rand.Next());
    8. var end = new Vector3(rand.Next(), rand.Next(), rand.Next());
    9.  
    10. timer.Start();
    11.  
    12. for (int i = 0; i < 10000000; ++i)
    13. {
    14. float distance = (start - end).magnitude;
    15. }
    16.  
    17. timer.Stop();
    18.  
    19. Console.WriteLine("Time using magnitude: {0}", timer.Elapsed);
    20.  
    21. timer.Reset();
    22. timer.Start();
    23.  
    24. for (int i = 0; i < 10000000; ++i)
    25. {
    26. float distance = (start - end).sqrMagnitude;
    27. }
    28.  
    29. timer.Stop();
    30.  
    31. Console.WriteLine("Time using sqrMagnitude: {0}", timer.Elapsed);
    32. Console.ReadLine();
    33. }
    34.  

    In a debug build I get:

    Code (csharp):
    1.  
    2. Time using magnitude: 00:00:03.7341929
    3. Time using sqrMagnitude: 00:00:02.7378231
    4.  
    So far, results are as expected. But lookit what happens in an optimized build:

    Code (csharp):
    1.  
    2. Time using magnitude: 00:00:00.0003228
    3. Time using sqrMagnitude: 00:00:00.0148509
    4.  
    Pretty strange, huh? I'm hoping someone who knows more about this than me can shed some light on these results. I realize these are extremely simple contrived tests, so perhaps I'm setting about this wrong.
     
    Last edited: Jun 12, 2015
    fontinixxl likes this.
  9. pvqr

    pvqr

    Joined:
    Apr 27, 2015
    Posts:
    38
    Did you finished watching all the videos? If the issue persists after you are done with the tutorial I can help you with that.
     
  10. pvqr

    pvqr

    Joined:
    Apr 27, 2015
    Posts:
    38
    Hmm.. in your Move method, you can try something like if the player hits "Q" or "E" key, your horizontal AND your vertical variables are equal to 1 or -1. That should work I guess.
     
  11. pvqr

    pvqr

    Joined:
    Apr 27, 2015
    Posts:
    38
    I couldn't find your question, sorry.
     
  12. pvqr

    pvqr

    Joined:
    Apr 27, 2015
    Posts:
    38
    Are you selecting them all at once? I think if you try one by one it won't work.
     
  13. NewPath

    NewPath

    Joined:
    Jun 11, 2015
    Posts:
    9
    I had this happen also on the latest version of Unity. Instead of prompting you to save, it just saves the animation in the current folder (Sprites). Just drag it into your Animation folder and rename it.
     
  14. snphillips0

    snphillips0

    Joined:
    Jun 12, 2015
    Posts:
    2
    I've been having this problem, but am completely unable to rename or even open the created animation. There are also almost no options in the inspector, just loop time, loop pose, and cycle offset. And the preview says "no model is available for preview. Please drag a model into this Preview Area."

    I just downloaded Unity 5 today, it's up to date, but I've been using 4 for a little bit. I don't know exactly what should be getting displayed or what, if anything, is wrong. Can you or anyone else on here help?
     
  15. NewPath

    NewPath

    Joined:
    Jun 11, 2015
    Posts:
    9
    You should be able to rename the file just by clicking it and hitting F2. What you are seeing in the inspector is the same that I have - you won't be able to visualize the animation there (I believe that you can only do that with 3D, not sure). You'll need to run the game to see if it's working. When the game is running you can hit the triggers manually on the animation controller to see the different animations.

    I'm fairly new to Unity, so perhaps somebody more experienced knows a way to preview the animation in the editor.
     
  16. snphillips0

    snphillips0

    Joined:
    Jun 12, 2015
    Posts:
    2
    Thank you so much! F2 worked perfectly, weird that I couldn't find any other way. And yeah, the animation works fine in game. I do wonder if there's not any other way to view it, though.
     
  17. Benarius

    Benarius

    Joined:
    Jun 11, 2015
    Posts:
    16
    Thx for the help. Some of the functionality is different. But the solutions helped. But right after clicking on the referenced animator controller, the node like disaplays all need to be renamed manually as well to PlayerIdle,PlayerChop and PlayerHit....well I hope it wont continue like that or I will fin another tutorial as I nee to learn quickly and not find out the differences between new and old versions...lol.
     
  18. Benarius

    Benarius

    Joined:
    Jun 11, 2015
    Posts:
    16
    Ok. I am starting part 4 now. A few bugs I can report. But I guess this is the wrong place. Please let me know.
     
  19. Benarius

    Benarius

    Joined:
    Jun 11, 2015
    Posts:
    16
    This tutorial is getting more and more frustrating. Now the scripts dont even work. I guess I just watch the series. But realy I learn best by watching and doing.
     
  20. Benarius

    Benarius

    Joined:
    Jun 11, 2015
    Posts:
    16
    Another day. What I am gonna do today is just repeat doing what I learned in the first 4 chapters without looking into the videos and see if I have grasped the skills of dungeon building, setting it all up in prefabs and animation folder. After all, thats a great starting point to learn the basics. I hope by then someone can explain how to make the scripts work. In addition what I would like to see is how the Sprite Sheets were created as whole and as single items. I saw other tutorials were they cut up the single items within Unity. Would be good to reference other options as well.
     
  21. Benarius

    Benarius

    Joined:
    Jun 11, 2015
    Posts:
    16
    Sorry, but I am going to abandon this tutorial. I redid all to video 5 and now Scripting errors. I have written the scripts as shown in video. I have copied and pasted the scripts as under the vidoes. I have debugged it all and just stupid errors. Am frustrated. Unless there is code that is correct, also code that can be copied and pasted which is workable for the stage the video is at. I even have used the ready scripts in the asset pack and modified. Zilch. I am so frustrated. I would realy like to do this whole tutorial. Gonna look for another till this is fixed.
     
  22. Zakharenko

    Zakharenko

    Joined:
    Jun 13, 2015
    Posts:
    1
    Hi! Thx for the great tutorial.
    I'm trying to do this tutorial step by step and i have problem on video 11.
    When i launch the game there's the mistake "NullReferenceException: Object reference not set to an instance of an object".
    It happens because Player.Start method executes before GameManager.Awake.
    How can i fix it?

    UPDATE. Found this http://docs.unity3d.com/Manual/class-ScriptExecution.html. Problem solved.
     
    Last edited: Jun 14, 2015
  23. John-Azar

    John-Azar

    Joined:
    Sep 3, 2014
    Posts:
    1
    Hi all,
    better late than never,
    Thanks guys for the awesome tutorial and great Unity, amazing :)
    I would like to share with all my customized edition of the game,as thanks for every one who helped me in unity. through comments and posts and tutorials ... sorry I don't know how to share all the project on github. maybe later I share it in asset store (for free of course), the whole project in cloud storage.
    https://drive.google.com/file/d/0B9qL6lg9L8JtRlcwZEl6V1RkS1E/view?usp=sharing
    feel free to edit and modify it as you like.
    this is the game on Google
    https://play.google.com/store/apps/details?id=en.johnazar.zombiesurvivor
    I am using Unity UI, Unity Ads, I made
    Thanks again
     
  24. pvqr

    pvqr

    Joined:
    Apr 27, 2015
    Posts:
    38
    Don't quit man! What errors are you having? Show them and let's find a solution together.
     
    John-Azar likes this.
  25. TheSuperhero

    TheSuperhero

    Joined:
    Jun 14, 2015
    Posts:
    2
    @Matthew Schell are you going to do a continuation to this series. It would help us a lot if you do few more stuff like a better enemy ai and more

    Thanks for the tutorials :D
     
  26. msbabybeast

    msbabybeast

    Joined:
    Jun 8, 2015
    Posts:
    4
    For the "Writing the Board Manager" part, I'm having trouble having the two enemies appear. The food, soda, walls, and exit sign are visible but the enemies are not. I copied and pasted Unity's version and modified the variable's names to match mine and it still didn't work. I also set the walls and outer walls to "None" to see if the tiles were covering the enemies and the enemies were still not visible. Also, when I ran my program, I noticed that it produced a clone of Enemy so I know that it probably exists but it's not visible anywhere. I'm guessing that the problem is not the code, it's the enemy animations. But I still can't figure out what the problem is.
     
  27. pwnsdisease

    pwnsdisease

    Joined:
    May 27, 2015
    Posts:
    5

    Thanks, guys! That did the trick and I am making really good progress. I haven't been able to work on it for about a week but now I am almost done with the project and am having a great deal of fun.
     
    Matthew-Schell likes this.
  28. RetroGamer28

    RetroGamer28

    Joined:
    Apr 28, 2015
    Posts:
    7
    I understand what he talking about as I mention a couple times that I ran into similar problems with this tutorial. My question was first asked on page 3 post 149 and if you check the image I posted I also run into message that comes up saying that there are issues with the board and game manager scripts because of the errors. In video 5 of this tutorial it says to add both scripts into an empty game object called game manager in the hierarchy. Then that same message in image 1 pops up hindering any advancement I would like to make for this tutorial. I'll re-post the codes again:

    Image2.jpg

    Image3.jpg

    Now for my current issue in image 2 I have these issues with the board manager and whatever I did to fix the problem these remain. What should I do to fix these? I have posted the script of the board manager for line 15 and 16.

    Code (CSharp):
    1. using UnityEngine;
    2. using System;
    3. using System.Collections.Generic;
    4. using Random = UnityEngine.Random;
    5.  
    6. public class BoardManager : MonoBehaviour {
    7. }
    8.     [Serializable]
    9.     public class Count
    10.     {
    11.         public int minimum;
    12.         public int maximum;
    13.  
    14.         public Count (int min, int max)
    15.         }
    16.             minimum = minimum;
    17.             maximum = maximum;
    Image1 1.jpg
     
    Last edited: Jun 16, 2015
  29. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Morning,

    from what I can see on the script that you have posted. you need to remove the closing brace on line 7, and the brace that you have on line 15 is the wrong way around (should be an opening brace { instead) hope that helps a bit.
     
  30. pvqr

    pvqr

    Joined:
    Apr 27, 2015
    Posts:
    38
    As @OboShape said, your brackets are messed up. Try this:
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System;
    4. using System.Collections.Generic;
    5. using Random = UnityEngine.Random;
    6.  
    7. public class BoardManager : MonoBehaviour {
    8.  
    9.     [Serializable]
    10.     public class Count { // this bracket opens your Count class
    11.         public int minimum;
    12.         public int maximum;
    13.  
    14.         public Count (int min, int max) { // this bracket opens your Count contructor method    
    15.             minimum = min;
    16.             maximum = max;
    17.         } // closing constructor
    18.     } // closing class
    19.  
    20. // YOUR BOARD MANAGER CODE GOES HERE
    21. }
    22.  
    And in your constructor, you probably want to feed the minimum and maximum value with the 'int min, int max' of the parameters, fix that too.
     
  31. pvqr

    pvqr

    Joined:
    Apr 27, 2015
    Posts:
    38
    If you drag your enemy prefab to the game, does it appear? I mean without running the game. This could be lots of things, maybe they are appearing but they are away from the screen, or behind other components.
    Move the enemy to the x = 2 and y = 2 while the game is running just to check if they are appearing but not in the screen.
    If that doesn't work, try to deactiave all the floor/walls/food while the game is running to check if they are behind the game board.
     
  32. Benarius

    Benarius

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

    I am not quitting. I just take another aproach. Just studied about State Machines. I know basically about 3D and 2D graphics and animation. My next step is making a game. I watched about 50 tutorials and followed and finished about 5. I know now a lot about Unity's inner workings. My basic questions have now been answered and with using what I learned, especially one great book about State Machines in Unity, I am ready and will come back to this tutorial to look for answers. But in general, my questions have been answered and I can continue happily with my project which is going well and hope to show it soon.
     
  33. msbabybeast

    msbabybeast

    Joined:
    Jun 8, 2015
    Posts:
    4
    When I dragged the enemy prefab to the Hierarchy, it appeared when I ran the game but it didn't appear when I wasn't running the game. I ran the program a few times and it seems like every time, there was something like Enemy1(Clone) that was produced and its position was on the board but it's not visible. I already deactivated the other things to see if they were covering the enemy and there still wasn't anything.
     
  34. Chng

    Chng

    Joined:
    Feb 11, 2015
    Posts:
    4
    Hey guys!

    I'm having some issues after part 11 of the tutorial, I manage to get everything working except the wall hit. It doesn't seem to be executing the OnCantMove function from the Player script at all, I tried;
    - copy and pasting the sample code provided but still no luck
    - I've double check the wall prefabs, they are on the BlockingLayer as well as listed as "items" under the sorting layer.
    - copy and paste the sample script for the MovingObject script
    - copy and paster the sample for Wall Script

    I can't think of anything else that could be causing the problem. Here is my Player script for reference
    Code (CSharp):
    1. {
    2.     public int wallDamage = 1;
    3.     public int pointsPerFood = 10;
    4.     public int pointsPerSoda = 20;
    5.     public float restartLevelDelay = 1f;
    6.  
    7.     private Animator animator;
    8.     private int food;
    9.  
    10.     protected override void Start()
    11.     {
    12.         animator = GetComponent<Animator> ();
    13.  
    14.         food = GameManager.instance.playerFoodPoints;
    15.  
    16.         base.Start ();
    17.     }
    18.  
    19.     private void OnDisable()
    20.     {
    21.         GameManager.instance.playerFoodPoints = food;
    22.     }
    23.  
    24.     void Update()
    25.     {
    26.         if (!GameManager.instance.playersTurn)
    27.             return;
    28.  
    29.         int horizontal = 0;
    30.         int vertical = 0;
    31.  
    32.         horizontal = (int) Input.GetAxisRaw("Horizontal");
    33.         vertical = (int)Input.GetAxisRaw ("Vertical");
    34.  
    35.         if (horizontal != 0)
    36.             vertical = 0;
    37.  
    38.         if (horizontal != 0 || vertical != 0)
    39.             AttemptMove<Wall> (horizontal, vertical);
    40.     }
    41.  
    42.     protected override void AttemptMove <T> (int xDir, int yDir)
    43.     {
    44.         food--;
    45.  
    46.         base.AttemptMove <T> (xDir, yDir);
    47.  
    48.         RaycastHit2D hit;
    49.  
    50.         CheckIfGameOver ();
    51.  
    52.         GameManager.instance.playersTurn = false;
    53.     }
    54.  
    55.     protected override void OnCantMove <T> (T component)
    56.     {
    57.         Wall hitWall = component as Wall;
    58.         hitWall.DamageWall (wallDamage);
    59.         animator.SetTrigger ("playerChop");
    60.         print ("hit");
    61.     }
    62.  
    63.     private void OnTriggerEnter2D (Collider2D other)
    64.     {
    65.         if (other.tag == "Exit")
    66.         {
    67.             Invoke ("Restart", restartLevelDelay);
    68.             enabled = false;
    69.         }
    70.         else if (other.tag == "Food")
    71.         {
    72.             food += pointsPerFood;
    73.             other.gameObject.SetActive(false);
    74.         }
    75.         else if (other.tag == "Soda")
    76.         {
    77.             food += pointsPerSoda;
    78.             other.gameObject.SetActive(false);
    79.         }
    80.      
    81.     }
    82.  
    83.     private void Restart()
    84.     {
    85.         Application.LoadLevel(Application.loadedLevel);
    86.     }
    87.  
    88.     public void LoseFood (int loss)
    89.     {
    90.         animator.SetTrigger ("playerHit");
    91.         food -= loss;
    92.         CheckIfGameOver ();
    93.     }
    94.  
    95.     private void CheckIfGameOver()
    96.     {
    97.         if (food <= 0)
    98.             GameManager.instance.GameOver ();
    99.     }
    100.  
    101.  
    102. }
    103.  

    I added the print function to check if it was running the OnCantMove function, but it doesn't appear to be running at all. Any ideas what could be the problem?

    EDIT- SOLVE. Apparently i didnt attach the Wall script to the wall prefabs. <:'D
     
    Last edited: Jun 18, 2015
  35. Benarius

    Benarius

    Joined:
    Jun 11, 2015
    Posts:
    16
    Btw...the book I mentioned is Learning C# by Developing Games with Unity 3D Beginner's Guide by Terry Norton. If you have 2 full days to spend (e.g. weekend) then do it. It makes really sense to learn the basics and using a State Machine.
     
  36. RetroGamer28

    RetroGamer28

    Joined:
    Apr 28, 2015
    Posts:
    7
    Thanks that fix these issues but now I ran into another issue when solving these in the board manager. Now is telling me that there is parse error on line 23.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System;
    4. using System.Collections.Generic;
    5. using Random = UnityEngine.Random;
    6.  
    7. public class BoardManager : MonoBehaviour {
    8.  
    9.     [Serializable]
    10.     public class Count    {
    11.         public int minimum;
    12.         public int maximum;
    13.  
    14.         public Count (int min, int max)    {
    15.             minimum = min;
    16.             maximum = max;
    17.         }
    18.     }
    19.  
    20.  
    21. }
    22.  
    23.     public internal columns = 8:
    24.     public internal rows = 8
    25.     public Count wallCount = new Count (5, 9);
    26.     public Count foodCount = new Count (1, 5);
    27.     public GameObject[] exit;
    28.     public GameObject[] floorTiles;
    29.     public GameObject [] wallTiles;
    30.     public GameObject[] foodTiles;
    31.     public GameObject[] enemyTiles;
    32.     public GameObject[] outerWallTiles;

    This is what line 23 states:

    Image1.jpg

    So why is internal consider an "unexpected symbol" when the tutorial told me to type that in? Now when I put those names it suggests are the "expected symbols" then it leads to telling me the same thing for the equal symbol.

    This is the image from mono:

    Image2.jpg
     
  37. Chng

    Chng

    Joined:
    Feb 11, 2015
    Posts:
    4
    Shouldn't it be "int" and not "internal"? You are suppose to make row and column an integer variable.

    EDIT: Also, your variables should be inside the BoardManager class. Check your brackets.
     
    Last edited: Jun 18, 2015
  38. RetroGamer28

    RetroGamer28

    Joined:
    Apr 28, 2015
    Posts:
    7
    That did fix line 23 but for some strange reason every time I fix an error and another pops up. Now its telling me that line 24 has a parsing error. I change internal to int and placed this ";" symbol at the end of the line but nothing changes. These are the images of the problem:

    Image1.jpg

    Image2.jpg
     
  39. Chng

    Chng

    Joined:
    Feb 11, 2015
    Posts:
    4
    Did you add ";" to line 23? cause its not showing in your image.
     
  40. pvqr

    pvqr

    Joined:
    Apr 27, 2015
    Posts:
    38
    I'm sorry to tell you this, but this tutorial might not be for you. You should start with a beginner tutorial and learn the basics of C#. I'm sure there are a lot of tutorials, books and documentation about Unity and C# for you.

    Anyway, this should work.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System;
    4. using System.Collections.Generic;
    5. using Random = UnityEngine.Random;
    6.  
    7. public class BoardManager : MonoBehaviour {
    8.  
    9.    [Serializable]
    10.    public class Count   {
    11.        public int minimum;
    12.        public int maximum;
    13.  
    14.        public Count (int min, int max)   {
    15.            minimum = min;
    16.            maximum = max;
    17.        }
    18.    }
    19.  
    20.    public int columns = 8;
    21.    public int rows = 8;
    22.    public Count wallCount = new Count (5, 9);
    23.    public Count foodCount = new Count (1, 5);
    24.    public GameObject[] exit;
    25.    public GameObject[] floorTiles;
    26.    public GameObject [] wallTiles;
    27.    public GameObject[] foodTiles;
    28.    public GameObject[] enemyTiles;
    29.    public GameObject[] outerWallTiles;
    30. }
    31.  
     
  41. RetroGamer28

    RetroGamer28

    Joined:
    Apr 28, 2015
    Posts:
    7
    That's still not going to stop me from asking for help and I want to get through this. Yes this fixed it but some strange reason yet again now it telling me there's a parsing error on line 98 but how can that be when there's nothing typed there at all. So when I delete that line then it goes to line 97 to state the same thing when again there's nothing typed on that line. Please understand this I have done everything the users here and the tutorial has told me to do in order fix this. I would like to continue this tutorial but these parsing errors prevent me and there's no reason for them to appear when I fixed them already.
     
  42. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    Thanks for watching. I don't think I'll do a continuation but you'll see in this thread many people have done modifications and their own versions.
     
  43. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    Make sure that the Enemy sprite renderer's sorting layer is set to Units and that the other prefabs are set to their appropriate sorting layers.
     
  44. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    @RetroGamer28 I think that some of the issues you're running into are down to a misunderstanding of certain C# scripting fundamentals. This tutorial is labelled as intermediate and assumes you know basic C# scripting. Looking at some of the errors you're getting stuck on I do think you might have a better time returning to this tutorial after learning some more C# fundamentals. I recommend taking a look at the resources here and then returning to this tutorial:

    http://unity3d.com/learn/tutorials/modules/beginner/scripting
     
  45. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    That's fantastic. Glad you're on track. Keep posting (in the appropriate forum!) if you run into any issues.
     
  46. kyungjae

    kyungjae

    Joined:
    Oct 16, 2014
    Posts:
    1
    Hi Matthew, first of all, thanks for the great tutorial. It helped me a lot for understanding fundamentals of Unity quickly. :)
    I found that calling Move() twice doesn't make the player actually 'move' twice,
    but found that it makes player's move speed doubled.
    for example, When I changed MoveTime value in Player object from 0.1 to 4, It took just 2 seconds when [if (Move (xDir, yDir, outhit)) SoundManager.instance.RandomizeSfx(moveSound1, moveSound2);] is added.

    How about changing return type of AttemptMove<T> from void to bool, to check if MovingObject started moving?
     
  47. Papadog

    Papadog

    Joined:
    Apr 25, 2015
    Posts:
    1
    check whether the sorting layers are in same order as on the video
     
  48. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    Hmmm, interesting suggestion I'll take a look. I added that last bit late in the process when I was implementing sound effects, this might be a good improvement.
     
    kyungjae likes this.
  49. MurDoK722

    MurDoK722

    Joined:
    Jun 9, 2015
    Posts:
    15
    I have the Final video to work on, which is adding mobile controls. I will do this today. However, I am still having the issue of the player taking one step and starving.
     
  50. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    I would try adding a Debug.Log statement to the AttemptMove function in Player for the GameManager playerFoodPoints variable. Also double check all your values in the inspector. Is playerFoodPoints starting off as zero in the GameManager?
     
Thread Status:
Not open for further replies.