Search Unity

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

Survival Shooter Q&A

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

  1. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Video 7, 16:15: for those who would be wondering (and provided it hasn't been posted here already), the "line renderer" can be found in "Add Component/Effects". ;)
     
    EwanRGR likes this.
  2. ohanzee

    ohanzee

    Joined:
    Mar 9, 2016
    Posts:
    3
    im want to remove the mouse in put in turning function what to replace it with


    and if please anyone can me integrating a jump function please i really i need to learn this
     
  3. li208xiao208long

    li208xiao208long

    Joined:
    Jun 17, 2016
    Posts:
    1
    For these who experienced this kind of error:
    On EnemyManager step, I try to drag and drop the Player to Enemy Manager (Script) Player Health, it remains as None (Player Health).
    I did check that Player has Component Player Health, so what's wrong?
    It takes me 3 hours to finally figure it out.

    For me, the Player Health Script on Player is from
    \assets\_completedassets\scripts\player\playerhealth.cs
    while the PlayerHealth playerHealth definition in EnemyManager.cs is actually from
    \Assets\Scripts\Player\PlayerHealth.cs

    As you see, even though the code inside two files are same, but sure they are not same PlayerHealth. That's the issue! Hope it helps to whoever is struggling on this.
     
  4. Dragon2000

    Dragon2000

    Joined:
    Jun 21, 2016
    Posts:
    3
    Cam settings.jpg Missing screen.jpg

    Unity 5 Survival Shooter
    Camera settings correct, but at run time, camera goes through floor, and get a 1/2 screen. Can anyone please help?
     
  5. Dragon2000

    Dragon2000

    Joined:
    Jun 21, 2016
    Posts:
    3
    Never mind. Such a DUFUS. Had void start() instead of void Start(). No LOL's please.
     
  6. Dragon2000

    Dragon2000

    Joined:
    Jun 21, 2016
    Posts:
    3
    @Douglas1701 - Just in case you check back here, my problem was I had void start () instead of void Start(). See if that is the issue.
     
  7. Dzergen

    Dzergen

    Joined:
    Jun 20, 2016
    Posts:
    1
    Hello I have a problem in Chapter 10, after starting the game triggers the Game Over window and then again when they die, why is triggered to death?
     
  8. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    To avoid that kind of confusion, the "done" or "completed assets" folders should be deleted, or at least removed and placed somewhere outside the project folder, or not downloaded at all. :)

    Also, do not make the mistake I made this morning (I wasn't very much awake): the Player that must be dragged into that slot is the instance of the Player in the hierarchy view, not the prefab! ;)
     
    EwanRGR likes this.
  9. Bex9

    Bex9

    Joined:
    Jul 6, 2015
    Posts:
    1
    How do I find the "root of the project" in the thing I downloaded. I can't find it. Please help!
     
  10. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Watch the video again; there is something you must do to avoid this.
     
  11. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    It's not very clear in the update pdf file for this project so I'm posting the GameOverManager script (video 10) as it should be:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class GameOverManager : MonoBehaviour
    6. {
    7.     public PlayerHealth playerHealth;
    8.     public float restartDelay = 5f;
    9.  
    10.     Animator anim;
    11.     float restartTimer;
    12.  
    13.     void Awake ()
    14.     {
    15.         anim = GetComponent<Animator> ();
    16.     }
    17.  
    18.     void Update ()
    19.     {
    20.         if (playerHealth.currentHealth <= 0)
    21.         {
    22.             anim.SetTrigger ("GameOver");
    23.  
    24.             restartTimer += Time.deltaTime;
    25.         }
    26.  
    27.         if (restartTimer >= restartDelay)
    28.         {
    29.             RestartLevel ();
    30.         }
    31.     }
    32.  
    33.     public void RestartLevel ()
    34.     {
    35.         SceneManager.LoadScene ("Level01");
    36.     }
    37. }
     
    konsic likes this.
  12. thehotdog

    thehotdog

    Joined:
    Jun 25, 2016
    Posts:
    5
    I am using Unity 5.3.5f1 to follow Survival Shooter tutorial. I downloaded the recommended project. At about 12:21 on vid 2 of 10, it requires an AnyState state in the animator. That state is not evident in the Animator. It is not obvious how to proceed.

    Screenshot here:
    anystate_.png

    Any help would be appreciated.
     
  13. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Any state is there, you must scroll the background to find it. Enlarge the window and you should find it. :)
     
  14. thehotdog

    thehotdog

    Joined:
    Jun 25, 2016
    Posts:
    5
    Thanks for the quick response. You're right, it is there. Enlarging the window didn't expose it, and there is no way to zoom that window, but you gave me an idea. I did a selection with the selection rectangle large enough to extend to the far left edge, then did a drag to the right. That succeeded - it dragged everything into view, including an Entry state and the AnyState.
     
  15. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    It's true that you cannot zoom into that window but you can move the background using the hand tool. :)
     
  16. thehotdog

    thehotdog

    Joined:
    Jun 25, 2016
    Posts:
    5
    That didn't work for me in the Animator window, actually. I had tried all of the tools (hand, cross, rotate, etc) with no effect. Left-click the mouse and it just presents a selection rectangle, irrespective of what tool is selected. If I drag the selection rectangle beyond the boundary of that window, it apparently does work -- it selected everything that was in the window so I could drag it into view.
     
  17. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Did you try the middle mouse button?
     
  18. thehotdog

    thehotdog

    Joined:
    Jun 25, 2016
    Posts:
    5
    That worked. The wireless mouse I have has a small thumb-wheel located where a middle button would be, and just aft of that a small button that I never use for any programming/editing work, and I never even think about. So at your suggestion I tried it just now and it worked to move the background in the Animator window! Thanks!
     
  19. monkeybrainz

    monkeybrainz

    Joined:
    Dec 16, 2015
    Posts:
    35
    I'm downloading the 5.x version of the project and starting over. there are some other small weird issues with using the 4.x project with 5.3 Unity and I'd like to see if this fixes them
     
  20. Warsson_013

    Warsson_013

    Joined:
    Jun 8, 2016
    Posts:
    1
    Hello good afternoon and goodnight!!

    I just downloaded Unity on my mac and so far I have been doing well with the Space Shooter and the Roll a Ball Tuts.

    But, I am having an issue with compiling this particular tut. It keeps giving me the same error with the Cross Platform Input Manager.
    [
    Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs(17,17): error CS0246: The type or namespace name `CrossPlatformInputManager' could not be found. Are you missing a using directive or an assembly reference?
    ]

    Would this be because I downloaded the packets for a lot of platforms at the very beginning or does this have to do with something else entirely? I have read up on the manual and the API and I haven't found any luck with it. If someone could point me to the direction on how they resolved this, that would be awesome.

    Thank you!
     
    orcinus likes this.
  21. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    I'm back to this because I was just working on a state machine and, I noticed that nothing of what I had said to you worked, except for the middle mouse button... Where did I take the rest? :)

    In fact, you can maximise the window by clicking on the top right of it:

    Sans titre-1.jpg
    Doing this should bring everything into view, including the "Exit" state. ;)
     
  22. DatGuyPotato

    DatGuyPotato

    Joined:
    Jul 14, 2016
    Posts:
    8
    Hi

    I have a problem with my animation for my player. Every time I start the game the refuse to use the walking animation but stays on Idle so my character is sliding over the map.

    I double checked everthing transition.the parameter and so on.

    here is a screen shot of my animation tab
    https://gyazo.com/19c8f437e49857380c8e7104aea9a78a
     
  23. Childish_Beast

    Childish_Beast

    Joined:
    Jul 15, 2016
    Posts:
    1
    Hey. Im having a problem with either the player health or the the enemy attacking. I made sure my coding was exactly like yours, but still my player isn't being harmed, or the enemy isn't attacking right.
    The enemy is going to the player and making contact, but still nothing. PLEASE HELP!!!
     
  24. Enderdragon101909

    Enderdragon101909

    Joined:
    Jul 15, 2016
    Posts:
    3
    So here is my problem after completing the enemy animation my Zombunny would do the animated walk but would not go anywhere and a error pops up saying,

    "EnemyMovement.Awake () (at Assets/Scripts/Enemy/EnemyMovement.cs:15)NullReferenceException: Object reference not set to an instance of an object "

    So I click on it and it takes me to this piece of code,

    "player = GameObject.FindGameObjectWithTag("Player").transform;" (Its under the awake function)

    So, I was wondering what I could have done wrong to let this happen.

    If anyone could help thx : )
     

    Attached Files:

  25. EdGann

    EdGann

    Joined:
    Jul 17, 2016
    Posts:
    8
    Did you select the Player Tag on your Player Object?
     
  26. Enderdragon101909

    Enderdragon101909

    Joined:
    Jul 15, 2016
    Posts:
    3
  27. Enderdragon101909

    Enderdragon101909

    Joined:
    Jul 15, 2016
    Posts:
    3
    Ya
     
  28. EdGann

    EdGann

    Joined:
    Jul 17, 2016
    Posts:
    8
    Hmm, well that line of code works. I just cut and pasted it into my code without a problem and your code looks fine. It's something to do with the Player Object, you might try deleting it from the Hierarchy and re-adding it from the Prefab Dir or the _CompletedAssets/Prefab Dir in the project menu. Also, the reference says that "FindGameObjectWithTag" can return an array, so if you have more than one Object tagged as Player that would cause a problem. Other than that, I am at a loss.
     
  29. EwanRGR

    EwanRGR

    Joined:
    Jan 5, 2014
    Posts:
    76
    I am looking to "extend" this by adding more rooms/levels, and a couple different endings. Am I allowed to use some/all of the resources in a game if I charge for it, or do I need to make sure I replace all of the models/textures? This might be answered elsewhere in this thread, but reviewing a couple pages didn't show anything obvious, and while there is a "Search Forum" there doesn't appear to be a "Search Thread". I did see the project is provided with the Apache License, and so presume that would need to be part of a credits page.
     
  30. tyler1213

    tyler1213

    Joined:
    Jul 28, 2016
    Posts:
    1
    Please help i keep getting error CS1513

    Here is my script


    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.         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 flootHit;
    44.  
    45.         if (Physics.Raycast (camRay, out floorHit, camRayLength, 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.         void Animating(float h, float v)
    55.         {
    56.             bool walking = h != 0f || void != 0f;
    57.             anim.SetBool ("IsWalking", walking);
    58.         }
    59.     }
     
  31. EwanRGR

    EwanRGR

    Joined:
    Jan 5, 2014
    Posts:
    76
    Line 56 shows you appearing to redefine void, which makes sense since the error you are getting is an MS Visual Studio error that happens when you try to redefine a reserved system variable. You might want to take another look at that line.
     
  32. DaveDong

    DaveDong

    Joined:
    Jul 29, 2016
    Posts:
    1
    It solves my problem,Thank you very much
     
  33. daPerley

    daPerley

    Joined:
    Jul 27, 2016
    Posts:
    3
    Hi, I've been working on this game to learn som basics the last cuple of days and everything works find execpt that the score ain't changing. I've used the scripts in the assets folder and removed all the comments added the scripts to the enemys and the player and so on.
    Should any other changes be done?
     
  34. oppaimandaisuki

    oppaimandaisuki

    Joined:
    Jul 30, 2016
    Posts:
    4
    Hey Guys, i'm a newbie, i wan't to make a game like survival shooter. but in first time, I got error message like this. i use a unity 5.3. Sorry for my bad english.
     

    Attached Files:

  35. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    These messages are not errors and they are about the scripts that are in the Completed folder. Get rid of this folder before beginning the project; it's content will interfere with your work.
     
  36. oppaimandaisuki

    oppaimandaisuki

    Joined:
    Jul 30, 2016
    Posts:
    4
    Thanks for your reply mam, that's not effect with my project right. in the another case, i got an error by Enemy Animation. When Character isDie or Enemy isDie the Enemy Animaton is doesn't playing. And I got this Message.
     
    Last edited: Jul 31, 2016
  37. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
    Please, post your EnemyHealth script, using the proper tags.
     
  38. oppaimandaisuki

    oppaimandaisuki

    Joined:
    Jul 30, 2016
    Posts:
    4
    i got the solution.. i just forget to put the EnemyAnimation to Animator Controller in Zombunny. :D.
     
  39. oppaimandaisuki

    oppaimandaisuki

    Joined:
    Jul 30, 2016
    Posts:
    4
    I Just Finish the tutorial but, when character Die and the scene is restart. The Scene Light Dark and i got a message error.
    Unity Error Survival Game.png

    And I change the loadscene code in GameOverManager with use the scene.Manager.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.SceneManagement;
    3. public class GameOverManager : MonoBehaviour
    4. {
    5.     public PlayerHealth playerHealth;
    6.     public float restartDelay = 5f;
    7.  
    8.     Animator anim;
    9.     float restartTimer;
    10.     void Awake()
    11.     {
    12.         anim = GetComponent<Animator>();
    13.     }
    14.  
    15.  
    16.     void Update()
    17.     {
    18.         Restart ();
    19.     }
    20.     void Restart()
    21.     {
    22.         if (playerHealth.currentHealth <= 0)
    23.         {
    24.             anim.SetTrigger("GameOver");
    25.             restartTimer += Time.deltaTime;
    26.             if (restartTimer >= restartDelay) {
    27.                 SceneManager.LoadScene ("Scene001");
    28.             }
    29.         }
    30.     }
    31. }
     
  40. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
  41. BlackAceZero777

    BlackAceZero777

    Joined:
    Jul 27, 2016
    Posts:
    24
    Hello Everyone, question because something weird is happening with my game: I have just finished Lesson 6, but when I tested my game and died, it restarts, but it restarts to a complete build of the game. I know I was having a problem with the editing the Player Health script where it kept telling me to fix the errors, but when I closed it and opened it, it was fine. What is going on with my build of the game?
     
  42. BlackAceZero777

    BlackAceZero777

    Joined:
    Jul 27, 2016
    Posts:
    24
    Can anyone help with this?
     
  43. yalavarthijaideep

    yalavarthijaideep

    Joined:
    Aug 2, 2016
    Posts:
    7
    I am having the same problem help!!!!!!!!!!!!!
     
  44. yalavarthijaideep

    yalavarthijaideep

    Joined:
    Aug 2, 2016
    Posts:
    7
    It is giving NullReferenceException: Object reference not set to an instance of an object
    EnemyAttack.Update () (at Assets/Scripts/Enemy/EnemyAttack.cs:56)
     
  45. yalavarthijaideep

    yalavarthijaideep

    Joined:
    Aug 2, 2016
    Posts:
    7
    it is giving null reference not set to an instance of an object enemy attack line 61
     
  46. yalavarthijaideep

    yalavarthijaideep

    Joined:
    Aug 2, 2016
    Posts:
    7
    Change
    Player = FindGameObjectWithTag("player").transform;
    to
    Player = Find("player").transform;
     
  47. Dave-Hampson

    Dave-Hampson

    Unity Technologies

    Joined:
    Jan 2, 2014
    Posts:
    150
    I'm not entirely sure what you mean by 'a complete build of the game'. Can you maybe record and post a video to show us what behaviour you are seeing?

    Did you perhaps not save the scene before exiting? Maybe you've lost some data?
     
  48. BlackAceZero777

    BlackAceZero777

    Joined:
    Jul 27, 2016
    Posts:
    24
    Hello Dave,

    I can't because I do not have the software to record videos but I did snap a picture which I will put as a thumbnail. Survival Shooter Game.PNG

    In summary, what happens is that when the enemy touches me, it does deal damage and I do die when my health is gone, but it reloads where the game is complete with music, multiple enemies and kill score. I am only in Lesson 6, so I don't know why this is happening.


    About the Player Health script, I was able to fix that. After saving, I needed to exit out of the Editor and enter back in.
     
  49. original-name

    original-name

    Joined:
    Aug 5, 2016
    Posts:
    3
    You want to go to File ---> Build Settings. Uncheck or delete the completed scene.
     
  50. BlackAceZero777

    BlackAceZero777

    Joined:
    Jul 27, 2016
    Posts:
    24
    It works after I did that. Thanks!