Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Survival Shooter Q&A

Discussion in 'Community Learning & Teaching' started by Adam-Buckner, Mar 26, 2015.

Thread Status:
Not open for further replies.
  1. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This thread is now closed and archived as this project has been updated for 5.1
    http://unity3d.com/learn/tutorials/projects/survival-shooter

    New thread here: http://forum.unity3d.com/threads/unity-5-survival-shooter-q-a.338190/





    This is the official thread for discussion, issues and Q&A for the Survival Shooter project

    Please use this thread if you have any questions, issues or feedback on this project.

    Survival Shooter is a learning project on our Learn Site:

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

    Learn how to make an isometric survival shooter game with this project from Unite training day 2014.

    Known Issues:

      • Please turn "annotations" on, as we try to annotate these videos if any issues are found. Many people turn annotations off, and miss these comments.
      • Unity 5: NavMesh needs to be baked with a different step height.
        • A step height of 0.35 should be used.
      • For the various animation controllers, when setting up the transitions, you need to uncheck the box for "Has Exit Time" in each transition. If you do not, you run into problems like the remainder of the Idle animation playing before the Move animation starts. [@Socrates]
     
    Last edited by a moderator: Jul 3, 2015
    Anthony12Na likes this.
  2. Socrates

    Socrates

    Joined:
    Mar 29, 2011
    Posts:
    787
    Additional issue that a number of people have run into: For the various animation controllers, when setting up the transitions, you need to uncheck the box for "Has Exit Time" in each transition. If you do not, you run into problems like the remainder of the Idle animation playing before the Move animation starts.
     

    Attached Files:

  3. cuzisaidso

    cuzisaidso

    Joined:
    Dec 29, 2014
    Posts:
    2
    I'm on Step 2 of the Sharp Shooter tutorial and noticed the Environment prefab is not being loaded correctly. This is a fresh download of the Survival Shooter, and I placed it into a new project (I previously did this same project in unity 4, but now getting errors so I decided to start over...it's a long story).

    upload_2015-3-26_17-24-17.png

    Also, MonoDevelop's autocomplete is not working properly as well. Vector1, Vector2, or Vector3 is not loading properly. Nor are any of the transform methods.
     
  4. Socrates

    Socrates

    Joined:
    Mar 29, 2011
    Posts:
    787
    I had to change the shader on the floor from an Legacy shader to a current one. This really helped make it look better. I was also getting some visual artifacts in the build with the Legacy shader.

    If you're getting errors on the environment, what are they?
     
  5. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    116
    The black artifacts are most likely bad lightmap data. In Unity 5, Enlighten will try and automatically bake anything marked static, like our environment here. Currently these meshes don't all have valid Lightmap UVs for Enlighten to bake to as the project wasn't initially intended for baking, so you get these weird black areas of overlaps and repeats.

    If you go to the project's models folder, select each environment and prop mesh and tick Generate Lightmap UV's in the asset's Inpsector Model tab, wait for Unity to create some valid UV's, then let Enlighten rebake, then you shouldn't see these weird errors anymore (hopefully!)
     
    Turnbull likes this.
  6. gilkzxc

    gilkzxc

    Joined:
    Mar 24, 2015
    Posts:
    5
    could you explain to me the problem and how to solve it in pm? thanks a head!
     
  7. gilkzxc

    gilkzxc

    Joined:
    Mar 24, 2015
    Posts:
    5
    :)Another problem?
    First image from video tutorial on Unity 4.6 secound on my Unity 5 project
    i don't have inaccuracy % so what to do insted changing it?
    setting the baking of the navMesh envoirment+zombo_CHAPTER4.png inUnity3D_5_mySurvivalShooting_navigation_bakingSetting_incompartibilityTOtutorial.png
     
    wake-unity and Anthony12Na like this.
  8. Adam-Buckner

    Adam-Buckner

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

    These threads need to be kept public so other people can search and learn from the discussion.

    I feel @peteorstrike did a good job of describing the issue in his post. What part is confusing?
     
    Ants95 likes this.
  9. meteoros

    meteoros

    Joined:
    Mar 19, 2015
    Posts:
    15
    Hi i'm getting 3 errors (i'm at the second video tutorial),it's about "Player Movement" scrip,any ideias what is wrong?

    1- Assets/Scripts/Player/PlayerMovement.cs(44,17): error CS1525: Unexpected symbol `{'

    2- Assets/Scripts/Player/PlayerMovement.cs(52,22): error CS0116: A namespace can only contain types and namespace declarations

    3- Assets/Scripts/Player/PlayerMovement.cs(57,1): error CS8025: Parsing error

    Code (csharp):
    1.  
    2.  
    3. public class PlayerMovement : MonoBehaviour
    4. {
    5.     public float speed =6f;
    6.  
    7.     Vector3 movement;
    8.     Animator anim;
    9.     Rigidbody playerRigidbody;
    10.     int floorMask;
    11.     float camRayLength = 100f;
    12.  
    13.     void Awake()
    14.     {
    15.         floorMask = LayerMask.GetMask ("Floor");
    16.         anim = GetComponent <Animator> ();
    17.         playerRigidbody = GetComponent <Rigidbody> ();
    18.     }
    19.     void FixedUpdate()
    20.     {
    21.         float h = Input.GetAxisRaw ("Horizontal");
    22.         float v = Input.GetAxisRaw ("Vertical");
    23.  
    24.         Move (h, v);
    25.         Turning ();
    26.         Animating (h, v);
    27.     }
    28.     void Move (float h, float v)
    29.     {
    30.         movement.Set (h, 0f, v);
    31.  
    32.         movement = movement.normalized * speed * Time.deltaTime;
    33.  
    34.         playerRigidbody.MovePosition (transform.position + movement);
    35.  
    36.     }
    37.     void Turning()
    38.     {
    39.         Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition);
    40.  
    41.         RaycastHit floorHit;
    42.  
    43.         if (Physics.Raycast (camRay, out floorHit, camRayLenght, floorMask)
    44.         {
    45.             Vector3 playerToMouse = flootHit.point - transform.position;
    46.             playerToMouse.y = 0f;
    47.  
    48.             Quaternion newRotation = Quaternion.LookRotation (playerToMouse);
    49.             playerRigidbody.MoveRotation (newRotation);
    50.         }
    51.     }
    52.         void Animating (float h, float v)
    53.         {
    54.             bool walking = h != 0f || v != 0f;
    55.             anim.SetBool ("IsWalking", walking);
    56.         }
    57. }
    58.  
     
    Last edited: Mar 30, 2015
    Anthony12Na likes this.
  10. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    When reading errors, the details can be broken down into:
    • The path to the item causing the error:
      • Assets/Scripts/Player/PlayerMovement.cs
    • The line number in the script (if we are pointing to a script), in this case, line 44:
      • (44,17)
    • The error number:
      • error CS1525
    • The error description:
      • Unexpected symbol `{'
    So, if you go to your script and look at line 44, you'll see a "{" that the compiler feels is out of place.

    The trick here is trying to find out why this apparently valid closed brace is out of place.

    If the compiler hits a brace that it's not expecting, and you feel it's correct, then back up a few steps! The compiler has tripped up and fallen down on that brace. What it's expecting is the second close parentheses that is missing from line 43!

    Code (csharp):
    1. if(Physics.Raycast(camRay, out floorHit, camRayLenght, floorMask)
    ... should be:
    Code (csharp):
    1. if(Physics.Raycast(camRay, out floorHit, camRayLenght, floorMask))
    Note the two opening parentheses: After the "if" and after the "Raycast". These both need to be closed.

    There is a phenomenon that I like to call a "cascade of errors". Once one error has been detected and one piece is out of place, the compiler will get confused and it can find other issues that may or may not be legitimate after the first error.

    At quick glance this error looks like the compiler was confused by the previous error:
    The final error is simply saying "I've reached the end and things are not correct. I didn't read everything correctly, and the script is now done. Help!":
     
    meteoros likes this.
  11. meteoros

    meteoros

    Joined:
    Mar 19, 2015
    Posts:
    15
    Thanks..it's solved:)
     
  12. meteoros

    meteoros

    Joined:
    Mar 19, 2015
    Posts:
    15
    Survival Shooter Tutorial - 4 of 10 - Adding Enemy one - Unity Official Tutorials (new)
    Hi, at 12:24 minute i've a GUI different from the one used in tutorial, how do i apply same values in my unity 5 version, check the images attached
    tut_img is a printscreen from the video tutorial.
    my_img is a printscreen from my unity 5 window

    for example i dont have the field "With Inaccuracy"...
     

    Attached Files:

    Anthony12Na likes this.
  13. meteoros

    meteoros

    Joined:
    Mar 19, 2015
    Posts:
    15
    I found the solution for this:

    "I am also new and currently working on this but I started it out on unity 5. Based on the change log in unity 5. "NavMesh bake settings: Removed width/height inaccuracy and allow to set voxel size instead."

    With that I tried enabling Manual Voxel Size and set Voxel size to 0.25 which is the default then it baked properly and runs with no error. Zombunny is following the player."
     
  14. Yardood

    Yardood

    Joined:
    Mar 29, 2015
    Posts:
    7
    Hello!
    It seems that I've done everything as explained in the second video,
    except in the state machine "entry", and "exit" thing.(cause they didn't have it in 4.6) but I think I got it to work,
    because when I hit play I can see the progress bars in the state machine go on and on,
    the transitions work as well!
    but in the game view - the animations aren't playing. its just a little sleepy survivor.. stuck there..
    (just to point out - the character moves and rotates perfectly.. again - its just the animations).

    i'm overcame by technology once more.
    Any suggestions?

    Unity screenshot.png
     
  15. Socrates

    Socrates

    Joined:
    Mar 29, 2011
    Posts:
    787
    Things that I would think to check:
    • Make sure the correct Motion is attached to each state.
    • See if I accidentally muted any states.
    • Is the AnimatorController attached to my character?
    • Am I watching the AnimatorController attached to my character?
    • Does the character have the correct avatar listed in the Animator? (PlayerAvatar).
     
    Yardood likes this.
  16. meteoros

    meteoros

    Joined:
    Mar 19, 2015
    Posts:
    15
    Hi, some times when i'm in play mode to test it, the background in the game tab is black, why is this happening?
     
    dvdhyh likes this.
  17. gilkzxc

    gilkzxc

    Joined:
    Mar 24, 2015
    Posts:
    5
    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....
    oho.png
     
  18. Yardood

    Yardood

    Joined:
    Mar 29, 2015
    Posts:
    7
    yes to everything, BUT!
    I decided to redo this tutorial, this time I remembered something that I did, I saved the first code before the instructor said to do so, and when the thing asked me if I wanna convert the line endings or keep them, I chose to keep them (not smart of me.)

    THIS TIME I pressed "Convert", Now everything works. (after I unchecked "Has exit time" in the transitions in the state machine.)

    I hope this information can be of use to anyone.
     
    Romeo_Cameo likes this.
  19. Socrates

    Socrates

    Joined:
    Mar 29, 2011
    Posts:
    787
    If you are using MonoDevelop, there is a setting to make them convert automatically. It not only avoids this issue, it avoids all those annoying pop-ups asking if you want to convert. :)

    Tools -> Options
    Scroll down to Text Editor -> General
    Set "Line ending conversion" to "Always convert line endings".

    If you are using Visual Studio, I'd expect it to have a similar setting, though I don't use the software and so do not know where it is.
     
    Yardood likes this.
  20. Yardood

    Yardood

    Joined:
    Mar 29, 2015
    Posts:
    7
    Cool! thank you dude :)
     
  21. Hansel-Doullery

    Hansel-Doullery

    Joined:
    Apr 8, 2015
    Posts:
    12
    Hello there.
    I'm new at using Unity, and I have a little issue with the part 7 of the turorial (harming enemies)
    The game is 100% functional, but when the player shoots, the line renderer that is drawn seems totally black sometimes, and sometimes it seems of the color of the material. I have been looking for solutions but haven't been able to find one so far. These are the properties of my line renderer component






    Thank you!
     
  22. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I don't know this project well off the top of my head.... But have you looked at LineRendererMaterial? Is this a pre-made material? Or do you set this up as part of the project? This may need to be updated to the standard shader or some other issue, but my guess is that the material you are using may be incompatible with Unity 5.
     
  23. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    116
    LineRenderMaterial was an included material but it may not behave super well in Unity 5 in certain build targets. I'd make sure your build settings are on PC/Mac/Linux Standalone and maybe switch the Shader to use the Standard Shader for better compatibility. I used the following settings and got a pretty comparable result:



    It may also be worth turning Cast Shadows and Receive Shadows 'off' in the Line Renderer component for this effect to look correct.
     
    dvdhyh likes this.
  24. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    116
    Actually, I've just tested the project in 5.0.1 and it looks like the Line Renderer is bugged to show only as black under certain shaders.

    If you're running the project under Unity 5.0.1 I'd suggest changing LineRenderMaterial to use an Unlit/Color shader instead, and it should look as expected!
     
    dvdhyh and Zamas like this.
  25. Hansel-Doullery

    Hansel-Doullery

    Joined:
    Apr 8, 2015
    Posts:
    12
    That actually worked!! really thanks!! I have finished the tutorial, and everything works excellent within Unity, BUT I have another issue. In the tutorial they do not explain how to build the proyect exactly, so I did it as the first two turorials explained, as a web player. But this does not seems to work, when I run the game, it pops up the same error several times. The error line is:

    "SetDestination" can only be called on an active agent that has been placed on a NavMesh

    After that, the enemies spawn but they do not move, the score text does not show and neither the game over text or the animation of the screen fader. However this error does not occur when I test in Unity, as I said before, and all the things I mentioned, work fine

    Why do you think this is happening?

    And again, really really thanks!
     
  26. SunstormGT

    SunstormGT

    Joined:
    Mar 18, 2015
    Posts:
    16
    I have 3 problems following the guide when working in Unity 5.x.:

    1) The textures in the scene are not quite what they should be.



    I was able to fix this by unchecking 'Precomputed Realtime UI' and 'Baked UI' under Lighting. I don't know if this is the right procedure as I'm new to Unity.

    2) On the Bake part of Navigation I have no 'Width Inaccuracy %'. I used the value 0.1524761 for voxel size which almost gives the floor a complete blue baked area. Are there other options to do this in a proper way?

    3) My biggest problem is when the player dies the game restarts and gets darker. I have no idea how to fix this. It happened after ch7. The repressing play the problem is gone but only till the player dies again and the game restarts.

    I think its the same problem this person has:

    http://forum.unity3d.com/threads/su...al-environment-texture-shader-problem.311681/

    Hope someone has an awnser to fix my 3rd problem as it is the most important. Thx in advance!
     
  27. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    116
    Hi @Hansel Doullery! My best guesses for this would be to double check when you're building that you have the right scene selected in the 'Scenes In Build' section of the Build Settings window. There's two scenes in the project by default (the starting point and the completed scene version), so it may be picking up the wrong one.

    Alternatively, you may just need to tweak the Navmesh settings. I have some settings here that should work flawlessly, although they may not be the most optimised:

     
  28. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    116
    I briefly describe how to fix this in post #5 above, but basically Enlighten is automatically running in this scene in Unity 5 and baking bad data due to how the scene was set up for Unity 4. Selecting all the props and environment meshes and checking on Generate Lightmap UV's as described above should fix this.

    The settings I've just posted above should work for this too!

    My best guess is that fixing the Lightmap UV's on the scene objects will fix this error. let me know if it doesn't and I'll try and investigate further!
     
  29. SunstormGT

    SunstormGT

    Joined:
    Mar 18, 2015
    Posts:
    16
    I found that when I turn off the 'cast shadow' on the floor object in the mesh renderer the textures are as they should be.

    Also found out that when I leave 'Precomputed Realtime UI' and 'Baked UI' checked everything turns black when the game restarts and then the baking starts which takes about 5 minutes and takes almost all of my CPU capicity. When I uncheck 'Precomputed Realtime UI' and 'Baked UI' again the scenes is normal again.

    For the last problem I can't find the option you spoke of.

    I quite new to Unity so sorry if I take your time asking simples things. If I go to the models folder and select each environment I dont have the option the change anything for it?
     
  30. peteorstrike

    peteorstrike

    Unity Technologies

    Joined:
    Oct 4, 2013
    Posts:
    116
    Hi @SunstormGT!

    My apologies, I wasn't very specific! I briefly outline in post #5 the steps to get Enlighten playing correctly with the scene so that you don't get this problem. I'll just copy-paste it here:

    And here's a screengrab showing the window, tab, and setting you're looking for - just make sure to do this to all the environment models and hit apply!

     
  31. SunstormGT

    SunstormGT

    Joined:
    Mar 18, 2015
    Posts:
    16
    Thx for your reply, I completely overlooked that tab. My apologies.

    I checked all 'Generate Lightmap UV' boxes in Assets > Models > Environment and hit apply.

    Nothing changed.

    I have to note that when I started the project I dragged the Environment prefab from Assets > Predfab to the Hierarchy tree. Does hitting apply update it in the entire project?

    Edit: something changed, the first problem I addressed is fixed. The weird textures are gone. But after I play the scene and the player died the screen still gets darker. After I press play again to stop the entire scene just gets black....

    Edit2: I found out that the 'getting darker' is the same as when I uncheck 'Continous Baking' in the Lightning tab. Same intensity 'darkning' as when after the player died. Hope this helps.

    Edit3: Found this post from a Unity dev:
    Guess its just a bug that triggers on Application.LoadLevel and we can do nothing about it for now.
     
    Last edited: Apr 10, 2015
  32. markblank05

    markblank05

    Joined:
    Apr 2, 2015
    Posts:
    29
    How can I change the gun accuracy with mouse, the way the game is design is to rotate the player with mouse position, but the aim are a little off because there are some offset from player position and gun position. how can i make the ray and line renderer to aim/cast the ray where my mouse is.

    2015-04-11_21-13-59.jpg

    as you can see, the raycast and the line are off. how can i change or fix the code?

    Code (CSharp):
    1. void Shoot ()
    2.     {
    3.         timer = 0f;
    4.  
    5.         gunAudio.Play ();
    6.  
    7.         gunLight.enabled = true;
    8.  
    9.         gunParticles.Stop ();
    10.         gunParticles.Play ();
    11.  
    12.         gunLine.enabled = true;
    13.         gunLine.SetPosition (0, transform.position);
    14.  
    15.         shootRay.origin = transform.position;
    16.         shootRay.direction = transform.forward;
    17.  
    18.         if(Physics.Raycast (shootRay, out shootHit, range, shootableMask))
    19.         {
    20.             EnemyHealth enemyHealth = shootHit.collider.GetComponent <EnemyHealth> ();
    21.             if(enemyHealth != null)
    22.             {
    23.                 enemyHealth.TakeDamage (damagePerShot, shootHit.point);
    24.             }
    25.             gunLine.SetPosition (1, shootHit.point);
    26.         }
    27.         else
    28.         {
    29.             gunLine.SetPosition (1, shootRay.origin + shootRay.direction * range);
    30.         }
    31.     }
    Code (CSharp):
    1. void Turning()
    2.     {
    3.         Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition);
    4.  
    5.         RaycastHit floorHit;
    6.  
    7.         if (Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))
    8.         {
    9.             Vector3 playerToMouse = floorHit.point - transform.position;
    10.             playerToMouse.y = 0f;
    11.  
    12.             Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
    13.             playerRigidbody.MoveRotation(newRotation);
    14.         }
    15.     }
     
    freddy57 likes this.
  33. mracey

    mracey

    Joined:
    Apr 15, 2015
    Posts:
    2
    Hi everyone,
    i'm currently doing the tutorial and am stuck on trying to figure out one thing, the enemy doesn't seem to "attack" me and deplete my health, yet alone show the flash-of-the-screen indicator/slider life bar decrease. I've used the stock scripts from the assets store for both the player (e.g. "PlayerHealth")
    PlayerHealth.png

    and enemy (e.g. "EnemyAttack")
    EnemyAttack.png

    respectively for the "player health" part of the tutorial. I've even copied and pasted the C# coding from the webpage and still no depleting health.

    i don't get any errors from mono develop or unity itself, from the console etc and am able to run it well (except for the enemy not attacking/taking away my health).

    i've even proceeded to the next part in the tutorial and complete "Harming enemies" and have been able to shoot the enemy and kill it, with no errors.

    any help would be greatly appreciated.
     
  34. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I don't know this project that well, but: if your scripts are correct, it must be in the way you've set up your scene. Double check all the settings against the video and completed tutorial to see what's gone off the rails.
     
  35. mracey

    mracey

    Joined:
    Apr 15, 2015
    Posts:
    2
    Hi Adam,
    thank you for replying. you know what? you're absolutely correct, it was my scene setup with the player character, i was missing the entire capsule collider component, along with the audio hurt component. now everything's coming up roses. thanks again mate!
     
  36. SarhanSoft

    SarhanSoft

    Joined:
    Apr 15, 2015
    Posts:
    63
    hello :)

    i have a problem when i build the game, and run it
    a light that show from gun is yellow, but light for Bullet is dark !
    when i test game is perfect no problem, but after build and run that show this error !
     
  37. Venom2506

    Venom2506

    Joined:
    Apr 19, 2015
    Posts:
    2
    Hello, I've been trying to go through this tutorial, I'm just done with the second part. I'll keep going as it's of little consequence (for now at least), but I have the "no animation" problem mentionned before. I did uncheck the "Has exit time" box on both transitions between walking and idle, I'm sure my code is correct (at some point I just went ahead and copied a confirmed functionnal one to be sure.
    What else could be wrong?
    What I find odd is that the gun is wobbling up and down when I walk around... feels like it's the animation that is not working properly, in fact.

    edit:
    I checked all this, no problem there. I hit the convert button for the script too.

    In the animator parameters, I have an entry box but no exit box, and I don't really know what to do with that entry box, maybe it's what causes the problem?
     
    Last edited: Apr 19, 2015
    Sir_Derick likes this.
  38. richdinoso

    richdinoso

    Joined:
    Apr 19, 2015
    Posts:
    5
    Hi, I have the same problem as Venom2506 above. The gun is moving when the character transitions from Idle to Move, but the character body is not doing anything. I see the same issue when the character dies... the gun falls off but the character remains standing. I previewed the animation in the assets->models-characters folder and it seems to be working fine, but it doesn't work during the game.
     
  39. MrBob350z

    MrBob350z

    Joined:
    Apr 20, 2015
    Posts:
    7
    Hello guys! i have this problem, i'm making the survival shooter game tutorial in unity and im getting this error:

    NullReferenceException: Object reference not set to an instance of an object
    PlayerMovement.Move (Single h, Single v) (at Assets/Scripts/Player/PlayerMovement.cs:31)
    PlayerMovement.FixedUpdate () (at Assets/Scripts/Player/PlayerMovement.cs:23)
    I think that i'm missing an object but i could not find which one..
    Here is the full script:

    using UnityEngine;

    public class PlayerMovement : MonoBehaviour
    {
    public float speed = 6f;

    Vector3 movement;
    Animator anim;
    Rigidbody playerRigidbody;
    int floorMask;
    float camRayLenght = 100f;

    void awake ()
    {
    floorMask = LayerMask.GetMask ("Floor");
    anim = GetComponent <Animator> ();
    playerRigidbody = GetComponent <Rigidbody> ();
    }
    void FixedUpdate ()
    {
    float h = Input.GetAxisRaw ("Horizontal");
    float v = Input.GetAxisRaw ("Vertical");
    Move (h, v);
    Turning ();
    Animating (h, v);
    }
    void Move (float h, float v)
    {
    movement.Set (h, 0f, v);

    movement = movement.normalized * speed * Time.deltaTime;

    playerRigidbody.MovePosition (transform.position + movement);
    }
    void Turning()
    {
    Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition);
    RaycastHit floorHit;
    if (Physics.Raycast (camRay, out floorHit, camRayLenght, floorMask)) {
    Vector3 playerToMouse = floorHit.point - transform.position;
    playerToMouse.y = 0f;
    Quaternion newRotation = Quaternion.LookRotation (playerToMouse);
    playerRigidbody.MoveRotation (newRotation);
    }
    }
    void Animating (float h, float v)
    {
    bool walking = h != 0f || v != 0f;
    anim.SetBool ("IsWalking", walking);
    }
    }
     
    attackontits likes this.
  40. Nuclearbacon

    Nuclearbacon

    Joined:
    Apr 20, 2015
    Posts:
    3
    I too am having the same issue as richdinoso and Venom2506 where when the animations play only the gun will move, not sure if its somewhere I went wrong or if its a change unity 5
     
  41. MrBob350z

    MrBob350z

    Joined:
    Apr 20, 2015
    Posts:
    7
    The animations in Unity 5 work perfect for me, so maybe you did something wrong, re-write you animation code, and re-build your playerAC
     
  42. richdinoso

    richdinoso

    Joined:
    Apr 19, 2015
    Posts:
    5
    I don't think it's the code or the PlayerAC. The gun works as intended, but the rest of the model does not. There's something wrong with the animation. The tutorial doesn't go into separating the different parts of the 3d model, so that problem won't be in the code or AC.
     
  43. Nuclearbacon

    Nuclearbacon

    Joined:
    Apr 20, 2015
    Posts:
    3
    Aye, I had already tried redoing both as it stands anyway.
     
  44. PolitelySpooky

    PolitelySpooky

    Joined:
    Apr 19, 2015
    Posts:
    3
    So, I've just finished the the tutorial and it all running okay apart from the fact that the score text and the health bar/ heart picture HUD isn't showing after I press play. Have I done something wrong?
     
  45. Pequisto

    Pequisto

    Joined:
    Apr 21, 2015
    Posts:
    66
    I'm experiencing the same issue although when I attempted to set my Drag and Angular Drag to Infinity, the value changed to 3.402823e+38. I believe this was flagged under Answers as something that will be fixed in a future update. Could this be causing the problem?
     
  46. Nuclearbacon

    Nuclearbacon

    Joined:
    Apr 20, 2015
    Posts:
    3
    Pequisto I had that issue as well, I'm uncertain I guess we will have to wait and see on the issue
     
  47. Venom2506

    Venom2506

    Joined:
    Apr 19, 2015
    Posts:
    2
    Same here actually, though I doubt it's related.
     
  48. Zamas

    Zamas

    Joined:
    Apr 15, 2015
    Posts:
    35
    Hi there.

    I found a solution to the walkig animation problem in that thread : http://forum.unity3d.com/threads/survival-shooter-tutorial-part-2-error.308208/.

    Just desable the "has exit time" option of the idle <-> move transition in the animator view. Also, disable it on the move <-> idle transition so that it change to the idle transition when you stop moving instead of continuing the walking animation for a few frame.

    No this bring a few questions. What is that "has exit time", what does it do and why did it cause an issue here ?
     
  49. Wanderous

    Wanderous

    Joined:
    Apr 21, 2015
    Posts:
    2
    Hello, @Adam Buckner ! Hoping to get some help. Stumped!

    Working in Unity 5, I've hit a wall on Phase 4 of all places - and am somewhat surprised it hasn't come up yet.

    I know you've said you aren't familiar with this project, so what happens in 4 is actually fairly simple. You drop an enemy (that will be turned into a spawn later) into the scene, and add a script that will have the enemy's NavMeshAgent move towards the Player each frame.

    In my project, the Enemy moves towards the players initial position (0,0,0), and that's it. Using the Debug log, I'm able to see the Player's transform.position change appropriately, but the reference to the player's transform captured in the Enemy's Awake() method seems to be unchanged. Logs show it stays at (0,0,0) per frame, as if the initial code were by reference, not value.

    Here's the enemy movement code, plus Debug.Log statements.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class EnemyMovement : MonoBehaviour
    5. {
    6.     Transform player;
    7.     //PlayerHealth playerHealth;
    8.     //EnemyHealth enemyHealth;
    9.     NavMeshAgent nav;
    10.  
    11.  
    12.     void Awake ()
    13.     {
    14.         player = GameObject.FindGameObjectWithTag ("Player").transform;
    15.         //playerHealth = player.GetComponent <PlayerHealth> ();
    16.         //enemyHealth = GetComponent <EnemyHealth> ();
    17.         nav = GetComponent <NavMeshAgent> ();
    18.     }
    19.  
    20.  
    21.     void FixedUpdate ()
    22.     {
    23.         //if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
    24.         //{
    25.         Debug.Log ("Player pos: " + player.position);
    26.         nav.SetDestination (player.position);
    27.         //}
    28.         //else
    29.         //{
    30.         //    nav.enabled = false;
    31.         //}
    32.     }
    33. }
    34.  
     
  50. Zamas

    Zamas

    Joined:
    Apr 15, 2015
    Posts:
    35
    I had the same problem with my first try. So i deleted my enemy and made a new one. And now it works perfectly. Don't know why it did not follow the player before. So try to make a new one to see if you have the same problem.
     
Thread Status:
Not open for further replies.