Search Unity

Survival Shooter Q&A

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

  1. Ty_u

    Ty_u

    Joined:
    Apr 22, 2014
    Posts:
    2
    Hey, I just started this tutorial after completing the Roll a ball and Space Shooter projects, which were really great!
    My problem is that the scene seems way darker than in the videos and screenshots I've seen of people on this thread and the old one.

    I deleted the original Directional Light, as requested in the PDF, and just dragged and dropped the Environment and Lights prefabs in the scene. I also noticed that in the Lights prefab I only have one directional light, but it seems there's a second, red one in the video?
    I looked at the completed scene to compare and it's also really dark...
     
  2. Elisa_C

    Elisa_C

    Joined:
    May 2, 2015
    Posts:
    1
    Hi, I need help, for some reason the camera will not follow the player, I'm not sure what's wrong... Also, the walking animation in the player takes a while to work, for some time it only slides/glides through the floor...
    (P.S. The first file is my camera script and the second one my player movement script)
    Please help me
     

    Attached Files:

  3. runtman

    runtman

    Joined:
    Jul 20, 2015
    Posts:
    3
    You need to change a setting on each environmental object inside the model folder, you need to check "Generate Lightmap UV, once you have applied it to all, you need to bake the game (this took 10 minutes for me) That should solve the dark issue.
     
  4. runtman

    runtman

    Joined:
    Jul 20, 2015
    Posts:
    3
    On the animation tab, click the transition and disable "has exit time" on each animating state.
     
    Oz31 and JuanFLZ like this.
  5. HaakonXCI

    HaakonXCI

    Joined:
    Dec 14, 2014
    Posts:
    3
    I found a bug and I'm not sure if it's project related or in Unity.

    I just finished video 7 and when I let my character die and have it sit there to respawn, the scene view goes white with inverted objects and the Game screen goes black with certain models showing.

    edit: I uploaded some screenshots here to show what's going on.
    • In the first image, everything is normal (this is just for a reference).
    • The second one is what happens after I die and the game restarts automatically (notice the floor how the lighting has slightly changed).
    • The third screenshot is what happens after the auto-restart while in-game and I choose to stop testing the game and am back in the editor mode.
     

    Attached Files:

    Last edited: Jul 22, 2015
  6. Emmanuel_Charon

    Emmanuel_Charon

    Joined:
    Jul 22, 2015
    Posts:
    4
    Hi,
    I need help with what I think is a lighting problem. I completed the project using Unity 5 and it works just fine in the Unity Editor. Now, I built it for the web using the "Web Player" option in Build Settings.

    It works fine on Firefox (just like the standalone build on mac OS X) but when I open it with Safari, the scene is very very dark. I guess it is a lighting problem but I don't know how to solve it. I also built it using the scene in the "_Completed" folder and got the same bug. Please help me understand what is going on here!
     
  7. Ty_u

    Ty_u

    Joined:
    Apr 22, 2014
    Posts:
    2
    Hey thanks! It already looks a lot lighter. But I still think there's something wrong with the lighting.
    First pic is my scene with only the environment and the lights prefabs, second is the complete scene in play mode (I understand there's a huge vignette over it but without it the scene is as dark as the first one), and third pic is what the game is supposed to look like apparently :/
    Maybe it's because the lighting system and standard material changed between Unity 4.6 and 5? I dunno.
     
  8. TomMakesGames

    TomMakesGames

    Joined:
    Apr 21, 2013
    Posts:
    37
    No-one seems to have solved that problem with the turning in lesson 2, and now I'm having the exact same problem.

    I've looked at the solutions provided here already, and no luck. Can't see a typo either and I've gone through the video with a fine toothcomb.

    Code:

    Code (CSharp):
    1. using UnityEngine;
    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.  
    20.     void FixedUpdate()
    21.     {
    22.         //Raw input gives us -1, 0, or 1 only. Nothing inbetween.
    23.         float h = Input.GetAxisRaw("Horizontal");
    24.         float v = Input.GetAxisRaw("Vertical");
    25.  
    26.         Move(h, v);
    27.         Turning();
    28.         Animating(h, v);
    29.        
    30.     }
    31.  
    32.  
    33.     void Move(float h, float v)
    34.     {
    35.         movement.Set(h, 0f, v);
    36.  
    37.         //Needs to be normalised because the vector of x=1 and y=1 is 1.4, so movement will be irregular
    38.         movement = movement.normalized * speed * Time.deltaTime;
    39.  
    40.         playerRigidbody.MovePosition(transform.position + movement);
    41.     }
    42.  
    43.     void Turning()
    44.     {
    45.         Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
    46.  
    47.         RaycastHit floorHit;
    48.  
    49.         if(Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))
    50.         {
    51.             Vector3 playerToMouse = floorHit.point = transform.position;
    52.             playerToMouse.y = 0f;
    53.  
    54.             Quaternion newRotation = Quaternion.LookRotation (playerToMouse);
    55.             playerRigidbody.MoveRotation (newRotation);
    56.         }
    57.     }
    58.  
    59.     void Animating (float h, float v)
    60.     {
    61.         bool walking = h != 0f || v != 0f;
    62.         anim.SetBool("IsWalking", walking);
    63.     }
    64.  
    65. }
    Error:

    Look rotation viewing vector is zero
    UnityEngine.Quaternion:LookRotation(Vector3)
    PlayerMovement:Turning() (at Assets/Scripts/Player/PlayerMovement.cs:54)
    PlayerMovement:FixedUpdate() (at Assets/Scripts/Player/PlayerMovement.cs:27)

    Can anyone help?
     
  9. TomMakesGames

    TomMakesGames

    Joined:
    Apr 21, 2013
    Posts:
    37
    Typical - you spend ages trying to work it out, and find out about 10 mins after you post in public.
    Still, will leave it here for others in case it helps.

    In the above at line 51 it says
    Code (CSharp):
    1.  Vector3 playerToMouse = floorHit.point = transform.position;
    when it should say:
    Code (CSharp):
    1.  Vector3 playerToMouse = floorHit.point - transform.position;
    i.e. swap the final '=' for a '-'.
     
  10. alphabeta314

    alphabeta314

    Joined:
    Jul 23, 2015
    Posts:
    47
    I installed 5.1.2f1, and when I click on Open In unity, it opens the Unity 5.1.2f1 projects window, but just sits there, nothing downloads, nothing opens or shows dealing with the shooter??
    any ideas how to download the file without clicking Open in Unity?
     
  11. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    just a thought , try opening the asset store window from within Unity. see if it works that way.
     
  12. Neo_the_Falcon

    Neo_the_Falcon

    Joined:
    Jul 25, 2015
    Posts:
    1

    In your case, the capsule collider should not be a trigger. So tick the IsTrigger to off. Then you should be fine.

    In my case, I have the same issue but I confirmed the trigger is off so I had no idea why my bullets go straight through. The reason was I thought the way to add things to the layer was at the very top so I missed it.

    upload_2015-7-25_12-28-41.png
     
  13. cstooch

    cstooch

    Joined:
    Apr 16, 2014
    Posts:
    354
    Sorry, pretty noobie to Unity (although not at all new to programming), so I apologize for just throwing out a question without a lot of info (but please let me know what you need to know to help this better).

    Anyways, I went through the tutorial (which is fantastic, BTW) and had one issue. When I shoot things, it seems like I have to hit in pretty precise areas for it to register as a hit. Like I'm talking there's a very small amount of pixels (lets say 3 or 4) where you can actually hit any of the enemies. Otherwise, it doesn't register as a collision/hit.

    To get around that, I increased the capsule size which I think seems to be working, but it seems like I shouldn't have to do that (meaning I'm thinking I messed something else up somewhere else and wondered if anyone had guesses where it could be).

    For example, on the Zombunny, I have the following settings:

    screen.jpg

    My radius was formerly 0.5 and height 1.5, but I could never hit the thing except for maybe on that one lucky shot where I'd find the magic pixel to make it register.

    Any ideas?
     
  14. Angelmax

    Angelmax

    Joined:
    Jul 26, 2015
    Posts:
    2
    Hi, i have problem with animation in Lesson 2. When i press walk, my chraracter walking, but animation isn`t working. Using Unity 5.1.2f1.
    Please help to decide my problem.

    Code:

    Code (CSharp):
    1. using UnityEngine;
    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 camRayLenght = 100f;
    12.  
    13.     void Awake ()
    14.     {
    15.         floorMask = LayerMask.GetMask ("Floor");
    16.         anim = GetComponent <Animator> ();
    17.         playerRigidbody = GetComponent<Rigidbody> ();
    18.     }
    19.  
    20.     void FixedUpdate()
    21.     {
    22.         float h = Input.GetAxisRaw ("Horizontal");
    23.         float v = Input.GetAxisRaw ("Vertical");
    24.  
    25.         Move (h, v);
    26.         Turning ();
    27.         Animating (h, v);
    28.     }
    29.  
    30.     void Move (float h, float v)
    31.     {
    32.         movement.Set (h, 0f, v);
    33.  
    34.         movement = movement.normalized * speed * Time.deltaTime;
    35.  
    36.         playerRigidbody.MovePosition (transform.position + movement);
    37.     }
    38.  
    39.     void Turning()
    40.     {
    41.         Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition);
    42.  
    43.         RaycastHit floorHit;
    44.  
    45.         if (Physics.Raycast (camRay, out floorHit, camRayLenght, floorMask))
    46.         {
    47.             Vector3 playerToMouse = floorHit.point - transform.position;
    48.             playerToMouse.y = 0f;
    49.  
    50.             Quaternion newRotation = Quaternion.LookRotation (playerToMouse);
    51.             playerRigidbody.MoveRotation (newRotation);
    52.         }
    53.     }
    54.  
    55.     void Animating(float h, float v)
    56.     {
    57.         bool walking = h != 0f || v != 0f;
    58.         anim.SetBool ("IsWalking", walking);
    59.     }
    60. }
    61.  
     
  15. Angelmax

    Angelmax

    Joined:
    Jul 26, 2015
    Posts:
    2
    Screenshot:
     

    Attached Files:

  16. cstooch

    cstooch

    Joined:
    Apr 16, 2014
    Posts:
    354
    Angelmax, first off, ensure your idle to move transition has IsWalking true for the condition. Also, make sure Has Exit Time is not checked or you will end up with a huge delay before your character's move animation kicks in. This is most likely the problem.
     
  17. aradar

    aradar

    Joined:
    Jul 28, 2015
    Posts:
    4
    I am on the mob spawning part and when it says to assign player health to EnemyManager in the "PlayerHealth" part it will not give me the option to choose player health script ? not sure wtf is going on up untill this the Tut was going very smooth

    useing unit 5.1.2f
     
  18. cstooch

    cstooch

    Joined:
    Apr 16, 2014
    Posts:
    354
    aradar: it's actually the player from the hierarchy that you drag in there.
     
  19. aradar

    aradar

    Joined:
    Jul 28, 2015
    Posts:
    4
    hmmm ok im pretty sure i tried that but maybe i didnt thanks .....on second look wow not sure how i over looked that or messed it up but lol works like a charm now had a derp moment i guess :/ 3 hours of sleep and mountain dew ftw :/
     
  20. Henrikera

    Henrikera

    Joined:
    Apr 9, 2015
    Posts:
    2
    So i was having some problems with video number 2 and the mouse-aim-turning thing and i managed to discover it by looking the documentation and im going to post here so maybe it helps someone else...
    My problem was inside Turning() and inside that "if (Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))"...
    I write a Debug.Log("The Ray Hit") inside that if and it was never called... so i went over the documentation and found out that "floorMask" was the information that is going to be ignored. All i had to do was:
    floorMask = LayerMask.GetMask ("Floor");
    floorMask = ~floorMask; //get all layers other than "Floor" so that all of them will be ignored
    and it´s good to go
     
    rmh16 and catscradle like this.
  21. gleftridge

    gleftridge

    Joined:
    Feb 2, 2014
    Posts:
    2
    I just found out something important involving the PlayerMovement class. If you are on a laptop and have a problem with the character not rotating due to touchpad movement, take a look at the completed code under the _CompletedAssets directory. In the Turning function, there is some code that uses CrossPlatformInputManager. You need to use that.
     
  22. gleftridge

    gleftridge

    Joined:
    Feb 2, 2014
    Posts:
    2
    I have noticed this problem with the slider as well and played around with the settings. So far, I am not seeing a way to fix it. Anyone have any ideas?

    Edit: Ah. I found the problem. It is the Fill Area game object under the one for the HealthSilder. You need to zero out the Left and Right values on it's transform. I also zeroed them out on the Fill game object.
     
    Last edited: Jul 29, 2015
  23. Skeleetor

    Skeleetor

    Joined:
    Jul 18, 2015
    Posts:
    3

    For your setDestination problem , try going into your EnemyMovement Script and ensure that you have no code that is needed commented out.

    lol, i went and paused the tut video, to go hunt and correct the error, i was scratching my head trying to figgure out how i missed that, then I continued the video. ahaha that made me chuckle.
     
    Last edited: Jul 29, 2015
  24. stopanatop

    stopanatop

    Joined:
    Jul 28, 2015
    Posts:
    1
    Hello
    iam new to unity and i tried to download the project it didnt c***inue always on 8%
    and i was wondering how can i design a character for a 3d game with unity
    and can you give me some links of companny make money with games dev
     
  25. ScarecrowBro

    ScarecrowBro

    Joined:
    Jul 29, 2015
    Posts:
    1
    I'm having problems with my script, but i can't figure out what they are. i followed the video exactly but there are still problems, i've tried redoing it twice and same thing. help please? here's a link to my project. This is my first project i'm attempting and i'm looking to get started with unity but i din't know what my issue is right now.

    https://drive.google.com/file/d/0B0ZloJegLzCIX3haMll4aWJFSTQ/view?usp=sharing
     
  26. Henrikera

    Henrikera

    Joined:
    Apr 9, 2015
    Posts:
    2
    Can anyone explain to me why the "if(Physics.Raycast (shootRay, out shootHit, range, shootableMask))" actually works with the current shootableMask value and why i had to swap my floorMask with ~floorMask value in "if (Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))"?
    In the first case it's ok to cast a ray into that shootable layer and in the other, the ray is totally ignoring whatever floorMask value i put in... I'm lost here
     
  27. Eocene3

    Eocene3

    Joined:
    Jul 18, 2015
    Posts:
    1
    I was having the same issue, it seems like you just need to go to the "Scene Lighting" object and change the intesity to about "1" in order to get lighting similar to the original project.
     
  28. Keeper75

    Keeper75

    Joined:
    Jul 28, 2015
    Posts:
    1
    Here are the best settings to keep the Health Slider aligned, with a complete empty slider (after the player dies):










    I hope this helps whoever wanted to fix this. ;)
     
    TheMaxim3498 likes this.
  29. gleb_buzik

    gleb_buzik

    Joined:
    Mar 15, 2015
    Posts:
    1
    I have encountered exactly the same issue like you and I still can not find the solution for it.
    Can anybody help?!
     
  30. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664

    Can you please learn to use code tag properly?

    http://forum.unity3d.com/threads/using-code-tags-properly.143875/
     
  31. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I don't know this project very well, but a null reference exception means you have code in a script trying to find, reference or use another object, but either the object is missing or the reference is bad.

    The error is telling you where.

    Look at line 57 in EnemyAttack.cs and see what you are trying to reference. This will be in the update function of enemy attack. This will help you diagnose what's wrong.
     
  32. IISAxxxPROPHETxxx

    IISAxxxPROPHETxxx

    Joined:
    Apr 6, 2015
    Posts:
    3
    Hello
    when I bake my nav mesh, there are massive gaps near objects and walls which I know the zombunnies won't pass
    Can anyone help me? Capture.PNG
     
  33. ohitsjustalf

    ohitsjustalf

    Joined:
    Aug 3, 2015
    Posts:
    1
    I keep trying to do the player movement script but it keeps saying i have an error (Eg: Assets/Scripts/Player/PlayerMovement.cs(47,45): error CS1525: Unexpected symbol `playerToMouse'). I keep getting rid of these, but they keep coming in. i followed the video tutorial but it just wont work. This is my script:
    using UnityEngine;

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

    Vector3 movement;
    Animator anim;
    Rigidbody playerRigidbody;
    int floorMask;
    float camRayLength = 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, camRayLength, 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);
    }
    }


    Please Help :(
     
  34. IISAxxxPROPHETxxx

    IISAxxxPROPHETxxx

    Joined:
    Apr 6, 2015
    Posts:
    3
    change Voxel size to either .40, or .45
     
  35. IISAxxxPROPHETxxx

    IISAxxxPROPHETxxx

    Joined:
    Apr 6, 2015
    Posts:
    3
    Hey,
    When I test the project in game mode (I am on part 6) The zombunny "hurt" me, but I can't die, I still have input and no death animation will play.
    I can't show you any code because I have no idea where this problem has come from!!!
     
  36. hatergonna8

    hatergonna8

    Joined:
    Aug 6, 2015
    Posts:
    1
    It says that the int and void for the player movement is and unexpected symbol
     
  37. Nunda

    Nunda

    Joined:
    Jun 25, 2015
    Posts:
    3
    I had this problem too, and the answer is later in this forum, but since no one replied to you directly you might have missed it. Also I'm writing this post so that other people who come across your post can find the answer easier simply by searching your name, as some people are like to do.

    Anyway Go to the animator window/tab and click the transition lines and uncheck "Has Exit Time".
     
    jbetts80, DaveDong and brainofsteel like this.
  38. winxalex

    winxalex

    Joined:
    Jun 29, 2014
    Posts:
    166
    Last edited: Aug 11, 2015
  39. adrianaaaa

    adrianaaaa

    Joined:
    Aug 7, 2015
    Posts:
    6
    The gunshots of my player go through the Zombunny without damaging/killing it. I have set my Zombunny's layer to "Shootable". Anyone else having this error? Thanks!
     
  40. IkoArtiaga

    IkoArtiaga

    Joined:
    Aug 8, 2015
    Posts:
    2
    Survival Shooter Tutorial - 3 of 10 : Camera setup - Unity Official Tutorials (new)

    can somebody help me, I can move my character everywhere but the camera don't follow in my character. why is that? please I need help anyone?
     
  41. Mamonchik

    Mamonchik

    Joined:
    Jul 13, 2015
    Posts:
    1
    Hello.
    Tell me please, what program did you use for modeling environment, and to create a model of the character and its animation.
    Thank you
     
  42. dwalker350

    dwalker350

    Joined:
    Aug 10, 2015
    Posts:
    1
    A problem I'm seeing is that there are TWO objects tagged with player - "Player" and "Player (Clone)", which is invisible, and does not appear in the hierarchy. Naturally, the enemies decided to attack the non-existing object. Selecting by name rather than tag does get around this bug.

    From my searches, this might be related to a bug where viewing the animation in a preview window added the clone. At any rate, exiting and re-starting Unity did clear the phantom clone, so SOMETHING caused him to spawn.

    To be safe, though, I'll use the slower but safer name search for now.
     
  43. tuto1902

    tuto1902

    Joined:
    Aug 12, 2015
    Posts:
    1
    I had a similar problem. My move animation wouldn't show until the idle animation finished. I solved by clicking on the transition and expanding the Settings (right above the timeline) and uncheck fixed duration. Also, for the Idle to Move transition I set the transition duration % to 0.01. That solved it for me.
     
    zvan92 likes this.
  44. IanSmellis

    IanSmellis

    Joined:
    Nov 2, 2014
    Posts:
    26
    Where in there series was the Menu to adjust the volume made?
     
  45. kevz32

    kevz32

    Joined:
    Oct 31, 2014
    Posts:
    1
    is there any tutorials on how to get the mobile system up and running, ive tried by myself but no luck
     
    HongyuYe and IanSmellis like this.
  46. HongyuYe

    HongyuYe

    Joined:
    Aug 15, 2015
    Posts:
    1
    How to converting Survival Shooter to mobile,how to use MobileInput that's inside the asset. I can't fount tutorial:(
     
  47. Kratlin

    Kratlin

    Joined:
    Aug 15, 2015
    Posts:
    2
    Hi, I started this tutorial today and ran into an issue on part 2 that others in this forum have had as well. The character does not look in the direction of the mouse. I have also narrowed down the problem to the Raycast code. I was so stumped that I copied the code from the tutorial page and it still didn't work.

    Code (CSharp):
    1. if(Physics.Raycast (camRay, out floorHit, camRayLength, floorMask))
    2.         {
    3.             Debug.Log("Entered if");
    4.             // Create a vector from the player to the point on the floor the raycast from the mouse hit.
    5.             Vector3 playerToMouse = floorHit.point - transform.position;
    6.            
    7.             // Ensure the vector is entirely along the floor plane.
    8.             playerToMouse.y = 0f;
    9.            
    10.             // Create a quaternion (rotation) based on looking down the vector from the player to the mouse.
    11.             Quaternion newRotation = Quaternion.LookRotation (playerToMouse);
    12.            
    13.             // Set the player's rotation to this new rotation.
    14.             playerRigidbody.MoveRotation (newRotation);
    15.         }
    Like others in this thread, read the documentation (http://docs.unity3d.com/Manual/Layers.html) but I interpret it to mean that the layerMask is in the Raycast to ignore all collisions except "Floor" layer. Like others, when I remove the layerMask from the Raycast code, the character tracks the mouse, but I worry that not using a mask could cause an issue later.

    So, my question is: Am I doing something wrong, and why does it not work?

    Here is the inspector for my Floor object.

    Thank you for any help you can provide.
     

    Attached Files:

  48. IanSmellis

    IanSmellis

    Joined:
    Nov 2, 2014
    Posts:
    26
    Try unchecking Convex and IsTrigger in the Floors MeshCollider.
     
  49. Kratlin

    Kratlin

    Joined:
    Aug 15, 2015
    Posts:
    2
    I turned off Convex and Trigger and I am having the same problem.
     
  50. Stefan_Hansen

    Stefan_Hansen

    Joined:
    Aug 16, 2015
    Posts:
    1
    I am having problems with harming enemies (part 7) as well, but for some reason it seems to be shooting from the back corner of the screen and is not accurate at all. I just copied the script straight from the assets and followed the components as in the video.