1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  3. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  4. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  5. Unity 5.5 is now released.
    Dismiss Notice
  6. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  7. Unity 5.6 beta is now available for download.
    Dismiss Notice

Survival Shooter Q&A

Discussion in 'Community Learning & Teaching' started by willgoldstone, Jul 3, 2015.

  1. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    563
    Hi everyone

    For those of you wishing to follow the Survival Shooter tutorial with Unity 5, we have created a new version of the Project assets, along with an upgrade guide located in the root of the project.

    We are busy making new projects so have not created new videos, but simply given you a guide to where in the videos you will need to do something different to the instructions onscreen.

    As you'll see from the guide, not much has changed and a lot of the difficulties those of you trying to run the tutorial in 5.x have been experiencing were actually with the source assets, so that's all taken care of.

    See the usual project page for a link to the new project on the Asset store which has everything you need.
    http://unity3d.com/learn/tutorials/projects/survival-shooter

    We recommend that you use the Unity version we tested this with or greater - Unity 5.1.1.

    Thanks for Peet Lee (peteorstrike) from our team for taking care of this!

    Enjoy!

    Will
     
    stopanatop likes this.
  2. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    490
    Thank you very much Mr. Will.
    I was having problem with Nav Mesh Generation, I hope I will find solution in the guide.
    thanks
     
    caicai67 likes this.
  3. midomady304

    midomady304

    Joined:
    Jun 29, 2015
    Posts:
    7
    i can't be turning with mouse please help me !! (
    using UnityEngine;


    Code (CSharp):
    1. public class PlayerMovement : MonoBehaviour
    2. {
    3. public float speed = 6f; // The speed that the player will move at.
    4.  
    5. Vector3 movement; // The vector to store the direction of the player's movement.
    6. Animator anim; // Reference to the animator component.
    7. Rigidbody playerRigidbody; // Reference to the player's rigidbody.
    8. int floorMask; // A layer mask so that a ray can be cast just at gameobjects on the floor layer.
    9. float camRayLength = 100f; // The length of the ray from the camera into the scene.
    10.  
    11. void Awake ()
    12. {
    13. // Create a layer mask for the floor layer.
    14. floorMask = LayerMask.GetMask ("Floor");
    15.  
    16. // Set up references.
    17. anim = GetComponent <Animator> ();
    18. playerRigidbody = GetComponent <Rigidbody> ();
    19. }
    20.  
    21.  
    22. void FixedUpdate ()
    23. {
    24. // Store the input axes.
    25. float h = Input.GetAxisRaw ("Horizontal");
    26. float v = Input.GetAxisRaw ("Vertical");
    27.  
    28. // Move the player around the scene.
    29. Move (h, v);
    30.  
    31. // Turn the player to face the mouse cursor.
    32. Turning ();
    33.  
    34. // Animate the player.
    35. Animating (h, v);
    36. }
    37.  
    38. void Move (float h, float v)
    39. {
    40. // Set the movement vector based on the axis input.
    41. movement.Set (h, 0f, v);
    42.  
    43. // Normalise the movement vector and make it proportional to the speed per second.
    44. movement = movement.normalized * speed * Time.deltaTime;
    45.  
    46. // Move the player to it's current position plus the movement.
    47. playerRigidbody.MovePosition (transform.position + movement);
    48. }
    49.  
    50. void Turning ()
    51. {
    52. // Create a ray from the mouse cursor on screen in the direction of the camera.
    53.  
    54. // Create a RaycastHit variable to store information about what was hit by the ray.
    55. RaycastHit floorHit;
    56.  
    57. // Perform the raycast and if it hits something on the floor layer...
    58. if(Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))
    59. {
    60. // Create a vector from the player to the point on the floor the raycast from the mouse hit.
    61. Vector3 playerToMouse = floorHit.point - transform.position;
    62.  
    63. // Ensure the vector is entirely along the floor plane.
    64. playerToMouse.y = 0f;
    65.  
    66. // Create a quaternion (rotation) based on looking down the vector from the player to the mouse.
    67. Quaternion newRotation = Quaternion.LookRotation (playerToMouse);
    68.  
    69. // Set the player's rotation to this new rotation.
    70. playerRigidbody.MoveRotation (newRotation);
    71. }
    72. }
    73.  
    74. void Animating (float h, float v)
    75. {
    76. // Create a boolean that is true if either of the input axes is non-zero.
    77. bool walking = h != 0f || v != 0f;
    78.  
    79. // Tell the animator whether or not the player is walking.
    80. anim.SetBool ("IsWalking", walking);
    81. }
    82. }
     
  4. rePhat

    rePhat

    Joined:
    Jun 25, 2015
    Posts:
    5
    Hello Midomady,

    your code seems to be correct. Did you set
    Code (CSharp):
    1. PlayerRigidBody = GetComponent<Rigidbody>();
    in your Awake() function?

    Also note, that the easiest way to debug your application is to print your variables and find exactly where the problem is. Try using sample code bellow for your turning function. When you find anything odd in the console ('null' being printed etc.) just click on that line. The editor should open your MonoDevelop at the line where the print was done.

    Hope that helps you a bit,
    rePhat

    Code (CSharp):
    1.  
    2.   void Turning() {
    3.      Debug.Log("camRay "+camRay);
    4.      RaycastHit floorHit;
    5.    
    6.      if(Physics.Raycast(camRay, out floorHit, camRayLength, floorMask)){
    7.        Vector3 playerToMouse = floorHit.point - transform.position;
    8.        playerToMouse.y = 0f;
    9.        Debug.Log("playerToMouse "+playerToMouse);
    10.      
    11.        Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
    12.        Debug.Log("newRotation "+newRotation);
    13.  
    14.        PlayerRigidBody.MoveRotation(newRotation);
    15.        Debug.Log("PlayerRigidBody "+PlayerRigidBody);
    16.      }
    17.      else
    18.        Debug.Log("ray didnt hit");
    19.    }
    20.  
     
    peteorstrike likes this.
  5. rePhat

    rePhat

    Joined:
    Jun 25, 2015
    Posts:
    5
    Hello,

    I'm trying to solve this issue to no avail and I'm getting quite desperate. :( Since the Environment is being stored within the assets as a prefab (not a model), I'm not able to access Model tab in my inspector.

    Any ideas?
     
    knighteousness likes this.
  6. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    563
    @rePhat - did you download the new Unity 5 version of the project and have this problem? very surprised as we've not seen this issue - which version of Unity are you seeing it with? remember we suggest Unity 5.1.1 or greater and the assets are setup for that.
     
  7. rePhat

    rePhat

    Joined:
    Jun 25, 2015
    Posts:
    5
    @willgoldstone Well, I've downloaded it a week ago, how old is the new version? I'm using v5.1.1. Also thanks for your quick response ;)

    EDIT: I'm downloading new assets, thanks!
     
    Last edited: Jul 3, 2015
  8. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    105
    Hello @rePhat! That's one of the main issues I wanted to get this update out to solve, so hopefully with the new assets and upgrade guide you should be good to go!
     
    rePhat and theANMATOR2b like this.
  9. jaimemh

    jaimemh

    Joined:
    Jul 4, 2015
    Posts:
    2
    Thank you so much for this! It arrived just at the right time. Loving the learning journey.

    I noticed a small mistake in the "04. CREATING ENEMY #1" Section of the PDF. The second paragraph indicates the time 01:20. It should be 11:20. It's obvious once you get to that part but for it could be confusing for some folks who are not paying enough attention.

    Again, thanks for the help with this. Here's hoping to see new tutorials soon!
     
  10. dvdhyh

    dvdhyh

    Joined:
    Jul 2, 2015
    Posts:
    1
    gilkzxc said
    i'm sorry for asking too many questions but.... something weird happend after i finished chapter 6 and everything worked fine the backgroung and the scene setting... disappeared... sort of....
    [​IMG]

    I am getting the same problem. Different from the other black scene issue. The background is black at the very start. Firing does provide lighting up the areas. So i guess it is a lightning problem, but appears at it should after you die once. So if i add lightning, i am over compensating after player respawn.
     
    Last edited: Jul 4, 2015
  11. jaimemh

    jaimemh

    Joined:
    Jul 4, 2015
    Posts:
    2
    I had that same problem a couple of minutes ago. After some searching on the forums, found out that apparently there's a bug where the Editor fails to bake the lights after Application.Loadlevel. To fix it, go to Window > Lighting > Lightmaps Tab and uncheck "Auto" to avoid continuous baking and then press Build.

    That worked for me!
     
  12. midomady304

    midomady304

    Joined:
    Jun 29, 2015
    Posts:
    7
    The problem is everything is ok !!!!!!!!!!! look at this ((((
    upload_2015-7-4_10-19-22.png
     
  13. rePhat

    rePhat

    Joined:
    Jun 25, 2015
    Posts:
    5
    @midomady304 I'm seeing just two variables and its not obvious which are theese.. Its generally good to print the same text, like your variable name in order to avoid confusion. The most important one for this particular task is your RigidBody., and therefore I have to ask you again, did u set your reference in the Awake() function?
     
  14. midomady304

    midomady304

    Joined:
    Jun 29, 2015
    Posts:
    7
  15. rePhat

    rePhat

    Joined:
    Jun 25, 2015
    Posts:
    5
    Yes, exactly this. Can you upload your project somewhere, so I can take a closer look? It may be of help for other people having the same problem :)
     
  16. midomady304

    midomady304

    Joined:
    Jun 29, 2015
    Posts:
    7
  17. midomady304

    midomady304

    Joined:
    Jun 29, 2015
    Posts:
    7
    the problem is when i started make this project 1st time everything was ok !!!!!
    now i tried and i have this problem (((((((
     
  18. uni00

    uni00

    Joined:
    Apr 23, 2015
    Posts:
    7
    I understand this is the new thread.

    I would like to point out a possible issue or bug in the C# script for "Creating Enemy #1" of the tutorial.

    http://unity3d.com/learn/tutorials/projects/survival-shooter/enemy-one

    This person's post from the old closed thread helped me get it working where the enemy just moved to the center of the level and stayed there moving and did not follow the player.

    http://forum.unity3d.com/threads/survival-shooter-q-a.313934/page-2#post-2101162

    So I also changed (Line 15) of that script from

    Code (CSharp):
    1. player = GameObject.FindGameObjectWithTag ("Player").transform;
    to

    Code (CSharp):
    1. player = GameObject.Find ("Player").transform;
    and it works, the enemy follows the player character

    I also notice that the summary tooltip description in MonoDevelop-Unity for Find has a description of what it does,
    "Finds a game object by name and returns it" but the FindGameObjectWithTag does not have a summary tooltip


    I have not yet made a full game using Tags all the way through in code but this would be a problem. Perhaps I need to work more with Tags in code to see them working. If I encounter anymore of these issues I will let Unity know somehow.
     
  19. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    563
    @jaimemh - thanks we've now updated the PDF, appreciate the help.
    @uni00 - thanks for pointing this out but not sure why it would not be working with tag, as the Player tag a) always exists in Unity projects and b) should be assigned to the player character during the tutorial.
     
  20. uni00

    uni00

    Joined:
    Apr 23, 2015
    Posts:
    7
    EDIT: I have solved my problem with
    Code (CSharp):
    1. FindGameObjectWithTag ("Player")
    I AM USING UNITY 5.1.1f1.

    I WAS NOT USING THE CORRECT ASSET PACKAGE FOR UNITY 5.1 WHEN I CREATED THE PROJECT.

    SO I HAVE CREATED A NEW PROJECT USING THE ASSET PACKAGE CALLED "Unity 5 Survival Shooter"

    (THE PACKAGE I WAS USING BEFORE WAS CALLED "Survival Shooter")

    Thank you for the help.
     
    Last edited: Jul 6, 2015
  21. FraGiuly

    FraGiuly

    Joined:
    Jun 1, 2015
    Posts:
    1
    Please help me!! I'm blocked at lession 2 and the animation of walking don't working. Why? Sorry my bad English, but I'm Italian.
     
  22. Adam-Buckner

    Adam-Buckner

    Unity Technologies

    Joined:
    Jun 27, 2007
    Posts:
    5,503
    Can you give us any more detailed information? Can you tell us what you've used as your setup? Where is the project it's breaking?
     
  23. U_nitty

    U_nitty

    Joined:
    Mar 8, 2015
    Posts:
    15
    Hi Guys,

    In the new asset package I downloaded as above, there was no 'floor' layer in the drop down list ??


    U_nitty.
     
    peteorstrike likes this.
  24. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    105
    Hi @U_nitty!

    Thanks for letting us know about this; it looks like the small fix we made to the pdf has nuked the project settings we needed. I'll disable the package for now and try and get a fix back online asap.
     
  25. midomady304

    midomady304

    Joined:
    Jun 29, 2015
    Posts:
    7
  26. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    105
    The fix for the missing project settings has just gone live to the asset store, so I'd suggest deleting the package from your local disk and then downloading the package fresh into an empty Unity project. If you step through the first two videos of the tutorial again you shouldn't be seeing any more errors.

    You can delete the package from the following folder:

    Win: C:\Users\USERNAME\AppData\Roaming\Unity\Asset Store-5.x\Unity Technologies\Unity EssentialsSample Projects\

    Mac: Users\USERNAME\Library\Unity\Asset Store-5.x\Unity Technologies\Unity EssentialsSample Projects\

    Hopefully downloading the fixed package and going through videos 1 and 2 again should also fix your problem, @midomady304 but please let us know if it doesn't.

    Sincere apologies for the inconvenience :(
     
    Last edited: Jul 6, 2015
    jaimemh and SirBiggs like this.
  27. SirBiggs

    SirBiggs

    Joined:
    Jun 10, 2015
    Posts:
    1
    Thanks, that fixed a lot of the problems I was having (including only the gun moving during the animation)
     
  28. U_nitty

    U_nitty

    Joined:
    Mar 8, 2015
    Posts:
    15
    @midomady304

    PlayerRigidBody.MoveRotation(newRotation);

    should be:

    playerRigidbody.MoveRotation(newRotation); // Set players rotation to this new rotation

    In your code you use PlayerRigidBody instead of playerRigidbody.

    Lowercase 'b' needed ?
    Lowercase 'p' needed ?

    U_nitty
     
  29. U_nitty

    U_nitty

    Joined:
    Mar 8, 2015
    Posts:
    15
    @peteorstrike
    I fixed it already by creating a user layer 'Floor' and creating and applying a tag 'Floor' .
    Thanks for the update - will download later :)

    Regards

    U_nitty
     
    peteorstrike likes this.
  30. Douglas1701

    Douglas1701

    Joined:
    Jul 7, 2015
    Posts:
    3
    Hello, I am having an issue with the camera setup in chapter 3. I followed the video tutorial but when I press play, the bottom half the game preview screen is cut off and the map disappears and becomes grey. The top half is visible but when I move it becomes transparent and looks weird. I re watched the tutorials and looked at my script and it all seems to be the same so I am confused at the moment. I am also running on unity 5.0.1fl because that is what my school is currently at so that might be part of the issue but I am unsure. Any help would be appreciated as I am very eager to learn!
     
  31. LouisGacke

    LouisGacke

    Joined:
    Jul 8, 2015
    Posts:
    1
    Hi, I completed the tutorial and everything works fine, except the scoring, everything is scoring twice, any ideas as where this bug may be?

    Thanks
     
  32. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    105
    Hi @Douglas1701! Quite difficult to say what the issue might be without seeing it first-hand but it might be worth double-checking that your camera settings match the completed scene (or indeed if the issue is present at all in the completed scene) - just in case it's something like the Camera Clipping Planes causing an issue. Here's my final camera settings:

    [​IMG]
     
    Last edited: Jul 8, 2015
  33. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    105
    Hello @LouisGacke!

    The score is controlled by this section of Enemy Health:

    Code (CSharp):
    1.  
    2.  
    3. public void StartSinking ()
    4.   {
    5.   // Find and disable the Nav Mesh Agent.
    6.   GetComponent <NavMeshAgent> ().enabled = false;
    7.  
    8.   // Find the rigidbody component and make it kinematic (since we use Translate to sink the enemy).
    9.   GetComponent <Rigidbody> ().isKinematic = true;
    10.  
    11.   // The enemy should no sink.
    12.   isSinking = true;
    13.  
    14.   // Increase the score by the enemy's score value.
    15.   ScoreManager.score += scoreValue;
    16.  
    17.   // After 2 seconds destory the enemy.
    18.   Destroy (gameObject, 2f);
    19.   }
    Might be an error or extra plus on the ScoreManager.Score section? Again, just guessing but it'll likely be something with this particular function being called twice or having an error somewhere.
     
  34. Douglas1701

    Douglas1701

    Joined:
    Jul 7, 2015
    Posts:
    3
    upload_2015-7-9_17-54-46.png
    All my camera settings were correct except depth and clear flags, I changed them and the issue is still there, here is a screenshot
     
  35. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    105
    Hello @Douglas1701

    If you check the Transform Component on your camera, you will see that the numbers are slightly different from the tutorial. Your Position is currently set to 0, 0, 10.38507 (the weird numbers in x and y with "e-" in them are basically floating point representation of 0's).

    Your position will need to be set to 1, 15, -22 for the camera to not clip through the level as it currently does. What's happened is that the camera with your current position settings is now partly sticking through the floor, which is why some of it is missing.
     
    jaimemh likes this.
  36. Willox

    Willox

    Joined:
    Jul 10, 2015
    Posts:
    1
    Hi!

    I'm having a problem on phase 2, as the animations don't work as they should. When I run the game, the Idle animation is shown. Fine so far. But when I try to move, the animation Move is not shown. It seems that only when Idle animation finishes, the Move animation is called; and when I stop moving, I have to wait again for Idle to finish.

    Also, if Idle animation finishes and I'm not moving, it gets stuck and no animation is shown.

    It doesn't seem to be a scripting error, as I see how the "IsWalking" parameters is set to true while i'm moving.

    How can I break the Idle animation for changing to the Move one?
     
    echuang98 likes this.
  37. JavadocMD

    JavadocMD

    Joined:
    Jul 9, 2015
    Posts:
    1
    I had a bit of debugging to do in the final phase of the project, and I've seen others with similar issues but no answer, so here's the way I fixed it.

    My problem was the Game Over animation/text was never shown, although the game would restart itself. I found that, unlike the video, the Player Death animation was set to fire an event "RestartLevel" which matched a function in the PlayerHealth script. The video shows the GameOverManager script as responsible for restarting, so I changed things to use that approach.

    In the Project view, go to Models -> Characters -> Player, and then in the Inspector's Animations tab, in Clips select "Death", expand the Events timeline, right click the tiny event marker and choose to delete it.

    The GameOverManager script given in the project did not match the one in the video, but it's simple to add the missing lines.

    Also make sure you check "Has Exit Time" in the state transition from "Empty State" to "Game Over Clip" on the HUD Canvas Animator. I'm not sure why, but that stopped the game over animation displaying as expected.
     
    Ifandbut, peteorstrike and jaimemh like this.
  38. RFan95

    RFan95

    Joined:
    Jul 11, 2015
    Posts:
    6
    I had the same problem as you. I don't know why it doesn't work but after some trying out
    I found a solution that will fix it.

    The only thing you have to do is replacing

    Code (CSharp):
    1. if (Physics.Raycast(camRay, out floorHit, camRayLength, floorMask))
    with

    Code (CSharp):
    1. if (Physics.Raycast(camRay, out floorHit, floorMask))
    So you don't give the camRayLength to the the Raycast method. It is surely no proper
    solution but it works fine :)
     
  39. Jacky2611

    Jacky2611

    Joined:
    Mar 2, 2013
    Posts:
    6
    Just wanted to point out that if your enemy only moves to 0/0 you have to replace "FindGameObjectWithTag(...)" with "Find(...)" in your EnemyMovement class.
    Find() uses the argument to find a game object with the same name (instead of looking for a tag), so it most likely is slower. If you really want to to fix this problem you should try to find a fix to use the tag.

    I found this "Bug" using the latest unity version for osx yosemite and the latest asset version.

    EDIT: Looks like uni00 already posted this, sry for reposting it. Found his post seconds after posting this.
     
  40. arnorush

    arnorush

    Joined:
    Nov 23, 2014
    Posts:
    1
    I'm trying to add a script to a player object but I keep getting the message "please fix compile errors before creating new script components." Even after removing the script component off of the player object, it has a "parsing error" on the lower left hand screen. Any help please? Thanks.
     
  41. kphipps

    kphipps

    Joined:
    Apr 26, 2013
    Posts:
    10
    I'm following the Survival Shooter tutorial. I'm on part 4 'Creating Enemy #1'. The NavMesh baking isn't coming out as it should. There are cracks and gaps in the floor. The enemy will not cross the larger gaps.

    I have Unity 5.1.1 and Unity 5 Survival Shooter 1.1b.

    I've used the settings changes from the Tutorial Upgrade Guide PDF, but still get these gaps between the floorboard edges.

    Any ideas as to what is wrong here?

    SS_NavMesh.png
     
    deuscide, Serruspancherrus and cassif like this.
  42. sonalikon

    sonalikon

    Joined:
    Jul 17, 2015
    Posts:
    1
    Hey! I am doing the Survival Shooter on Unity 5, and I was stuck on Harming Enemies. My gun fires, and the line renderer and lighting and everything works fine, but the line passes through the zombunny, or at least doesn't harm it. I don't know if this is the problem, but the Zombunny seems to be "not solid", the player can pass through it with a little resistance. These are the properties for Zombunny.

    [​IMG]

    Also, this doesn't bother me a whole lot, but my slider works, its just that that it doesn't start all the way full, even though it says it is full.

    [​IMG]

    Any ideas what to do? Thanks in advance!
     
  43. TheBlackMarmoset

    TheBlackMarmoset

    Joined:
    Jul 17, 2015
    Posts:
    2
    I'm having this same problem, if you figure out what the solution is please message me sir! :)
     
  44. kalimann

    kalimann

    Joined:
    Apr 4, 2015
    Posts:
    1
    I'm in the last phase, "Game Over". I created the animation (seemingly working) with all the elements for the HUD including canvas etc.

    However the game starts by playing the animation, thus hindering me in playing the game since the view gets blocked out. I don't know what causes this, since the trigger should be set correctly in the animator controller. I made sure the "Has Exit Time" is unchecked in the AC. Other things that could be relevant to check?
     
  45. Sabreur

    Sabreur

    Joined:
    Jul 13, 2015
    Posts:
    1
    I am having the exact same issue, my problem matches the screenshot perfectly. Any solution would be greatly appreciated.

    EDIT: While it's not perfect, I got semi-decent results by increasing the voxel size. The holes around objects are a little big, but the mysterious holes in the middle of nowhere are gone.

    My Settings:

    Agent Radius: 0.75
    Agent Height: 1.2
    Max Slope: 45
    Step Height: 0.34 (Unity warns about the max slope)

    Drop Height: 0
    Jump Distance: 0

    Voxel Size: 0.28 - This required some tricky fine-tuning. Too big, and the nav mesh couldn't fit between objects. Too small, and the mysterious holes appeared. It still allows for a LOT of space around obstacles, so it's not quite ideal. But it should be good enough to finish the tutorial at least.

    Min Region Area: 2

    I think the moral of the story is to avoid having complex, bumpy, jagged floor meshes - it seems the navmesh system has trouble telling the difference between a crack in the floor and an impassible chasm. If you've got floor with bumps and creases and whatnot, use a shader to add the bumps instead of putting the bumps in the actual geometry to make the navmesh's job easier. Anyone with more experience can feel free to contradict me here!
     
    Last edited: Jul 18, 2015
    Synser and catscradle like this.
  46. BarneytheDinoDuck

    BarneytheDinoDuck

    Joined:
    Jul 17, 2015
    Posts:
    7
    Can someone please help me out!!!!!!!! I am up to part 7 and i finished it and when i went to play the zombunny wouldnt die what happens is that when i kill him the sound plays but the animation doesnt play and he keeps following me round and he can still hurt me. I found this error
    NullReferenceException: Object reference not set to an instance of an object
    PlayerHealth.Update () (at Assets/Scripts/Player/PlayerHealth.cs:38)
    and when i double click it opens up the player health script and takes me to line 38 which is blank except for one of these }
     
  47. BarneytheDinoDuck

    BarneytheDinoDuck

    Joined:
    Jul 17, 2015
    Posts:
    7
    THIS IS MY SCRIPT IF IT HELPS

    using UnityEngine;
    using UnityEngine.UI;
    using System.Collections;

    public class PlayerHealth : MonoBehaviour
    {
    public int startingHealth = 100; // The amount of health the player starts the game with.
    public int currentHealth; // The current health the player has.
    public Slider healthSlider; // Reference to the UI's health bar.
    public Image damageImage; // Reference to an image to flash on the screen on being hurt.
    public AudioClip deathClip; // The audio clip to play when the player dies.
    public float flashSpeed = 5f; // The speed the damageImage will fade at.
    public Color flashColour = new Color(1f, 0f, 0f, 0.1f); // The colour the damageImage is set to, to flash.


    Animator anim; // Reference to the Animator component.
    AudioSource playerAudio; // Reference to the AudioSource component.
    PlayerMovement playerMovement; // Reference to the player's movement.
    PlayerShooting playerShooting; // Reference to the PlayerShooting script.
    bool isDead; // Whether the player is dead.
    bool damaged; // True when the player gets damaged.


    void Awake ()
    {
    // Setting up the references.
    anim = GetComponent <Animator> ();
    playerAudio = GetComponent <AudioSource> ();
    playerMovement = GetComponent <PlayerMovement> ();
    playerShooting = GetComponentInChildren <PlayerShooting> ();

    // Set the initial health of the player.
    currentHealth = startingHealth;
    }


    void Update ()
    {
    // If the player has just been damaged...
    if(damaged)
    {
    // ... set the colour of the damageImage to the flash colour.
    damageImage.color = flashColour;
    }
    // Otherwise...
    else
    {
    // ... transition the colour back to clear.
    damageImage.color = Color.Lerp (damageImage.color, Color.clear, flashSpeed * Time.deltaTime);
    }

    // Reset the damaged flag.
    damaged = false;
    }


    public void TakeDamage (int amount)
    {
    // Set the damaged flag so the screen will flash.
    damaged = true;

    // Reduce the current health by the damage amount.
    currentHealth -= amount;

    // Set the health bar's value to the current health.
    healthSlider.value = currentHealth;

    // Play the hurt sound effect.
    playerAudio.Play ();

    // If the player has lost all it's health and the death flag hasn't been set yet...
    if(currentHealth <= 0 && !isDead)
    {
    // ... it should die.
    Death ();
    }
    }


    void Death ()
    {
    // Set the death flag so this function won't be called again.
    isDead = true;

    // Turn off any remaining shooting effects.
    playerShooting.DisableEffects ();

    // Tell the animator that the player is dead.
    anim.SetTrigger ("Die");

    // Set the audiosource to play the death clip and play it (this will stop the hurt sound from playing).
    playerAudio.clip = deathClip;
    playerAudio.Play ();

    // Turn off the movement and shooting scripts.
    playerMovement.enabled = false;
    playerShooting.enabled = false;
    }
    }
     
  48. kingcrust

    kingcrust

    Joined:
    May 22, 2015
    Posts:
    1
    So i finished the tutorial and i don'y know which one of the asset package files i got but i do have two problems
    one is that its saying (
    "SetDestination" can only be called on an active agent that has been placed on a NavMesh.
    UnityEngine.NavMeshAgent:SetDestination(Vector3)
    EnemyMovement:Update() (at Assets/Scripts/Enemy/EnemyMovement.cs:25)
    )
    but all my enemy's have NavMesh Agents on them so idk what to do


    the second problem is that the Game Over animation doesn't even start when my player dies
     
  49. BarneytheDinoDuck

    BarneytheDinoDuck

    Joined:
    Jul 17, 2015
    Posts:
    7
    NullReferenceException: Object reference not set to an instance of an object
    EnemyAttack.Update () (at Assets/Scripts/Enemy/EnemyAttack.cs:57)
    Can someone please help me with this error.
     
  50. runtman

    runtman

    Joined:
    Jul 20, 2015
    Posts:
    3
    Hey guys, firstly I would like to say I am a junior programmer so it was cool that you guys focused on the engine rather than the code it's self.

    Secondly, I seem to have this bug where i am actually able to pass through the floor objects, which then reveals another bug where the enemy can't find me. I can't lose! It's awesome right?

    [​IMG]

    You can see I am in the middle of the toy there, the enemy can't find me. I have tried repeating part 1 of the tutorial again but I haven't had much joy. I am also able to walk off the edge of the map and keep going. What am I missing here?