Search Unity

Survival Shooter Q&A

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

  1. BlackAceZero777

    BlackAceZero777

    Joined:
    Jul 27, 2016
    Posts:
    24
    Hello all once again, I am having a problem when it comes to scoring points after killing an enemy. I have put the scripts in the right places and have taken off the forward slashes in the Enemy Health script, but it is not giving me points when I test it. What is happening?
     
  2. orcinus

    orcinus

    Joined:
    May 7, 2013
    Posts:
    15
    Anyone knows where is the CrossPlatformInputManager defined? Unity's own sample simply doesn't work and a search for this class fails miserably in the docs online.
     
  3. Deleted User

    Deleted User

    Guest

    It's in the Standard Assets Example Project. If you haven't downloaded it when you installed Unity, run the installer and select it in the installer window.
     
  4. orcinus

    orcinus

    Joined:
    May 7, 2013
    Posts:
    15
    I did... that's the first thing I've checked out. :)
     
  5. sadaf550

    sadaf550

    Joined:
    Jul 4, 2016
    Posts:
    9
    Thank you uni00 for asking this question and finding the solution :D I had exactly same problem, and I solved it by your method and it works like a gem!!

    I am using unity 5.3 and I cant find the unity 5 package you were talking about, after searching thoroughly, I came to the conclusion that I already was using the unity 5 package..!
    anyways, my game is working fine now, all thanks to u :)
     
    Last edited: Aug 16, 2016
    Francescalapisi86 likes this.
  6. sadaf550

    sadaf550

    Joined:
    Jul 4, 2016
    Posts:
    9
    I am using Unity 5.3, I have been doing just fine till it came to "Player Health" phase 6... my player wont get hurt, no matter how close the enemy gets...
    there is these errors coming up: aasaa.jpg I havent touched the scripts, so there shouldnt be any issue...
    Though I did try to play with it, I changed:
    Code (CSharp):
    1. GameObject.FindGameObjectWithTag("Player");
    to
    Code (CSharp):
    1.  GameObject.Find("Player");
    still no use..
    I also tried to change the gameobject to public and assigned it in the fields, but it was no use...
    I think it is this version compatibility issue..
    what should I do? :/
    anyone?
     
    MustardPirate and Ohmeoh like this.
  7. Papademos

    Papademos

    Joined:
    Aug 18, 2016
    Posts:
    3
    I've been seeing this error since I've started this project:

    Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs(41,17): error CS0246: The type or namespace name `CrossPlatformInputManager' could not be found. Are you missing a using directive or an assembly reference?

    A lil help in fixing this would be greatly appreciated ^.^ I've only completed the first video so far, if that helps with how much I've done. I haven't messed with the scripts in any way. I'm also using unity 5.4. Thanks in advance!
     
  8. Deleted User

    Deleted User

    Guest

    This error message is about a script that doesn't belong to your project but to the the Standard Assets; remove them from your project; they are interfering.
     
  9. Papademos

    Papademos

    Joined:
    Aug 18, 2016
    Posts:
    3
    what would be the safest way to remove it without derailing the project?
     
  10. Deleted User

    Deleted User

    Guest

    Removing them won't derail the project since they have nothing to do with it. :)
     
  11. Papademos

    Papademos

    Joined:
    Aug 18, 2016
    Posts:
    3
    ok cool, thank you for your help! ^.^
     
  12. Ohmeoh

    Ohmeoh

    Joined:
    Aug 20, 2016
    Posts:
    2
    I HAVE THE SAME ISSUE!! Someone please help
     
  13. mpmont1979

    mpmont1979

    Joined:
    Aug 24, 2016
    Posts:
    1

    Changing my C# script to GameObject.Find ("Player").transform absolutely worked for me! Thank you very much!!
     
    Tradge20 likes this.
  14. PJSkittles

    PJSkittles

    Joined:
    Nov 9, 2015
    Posts:
    5
    I keep getting the "All compiler errors have to be fixed before you can enter playmode!" error message even after I have fixed all the errors. The controller doesn't even pop up now. (I am working on the Player Movement phase)

    *Edit* I missed something, which now lets me hit play, however I am getting this error:


    ArgumentException: Input Axis horrizontal is not setup.
    To change the input settings use: Edit -> Project Settings -> Input
    PlayerMovement.FixedUpdate () (at Assets/Scripts/Player/PlayerMovement.cs:22)
     
    Last edited: Aug 24, 2016
  15. Ehanho24

    Ehanho24

    Joined:
    Aug 25, 2016
    Posts:
    1
    Help please,

    Im up to the harming enemy step and everything works as intended accept that when the bullet hits the enemy its health is unchanged and nothing happens, any advice

    thanks
     
  16. PJSkittles

    PJSkittles

    Joined:
    Nov 9, 2015
    Posts:
    5
    Is my camera messed up or is this a rendering error. 2016-08-25.png
     
  17. PJSkittles

    PJSkittles

    Joined:
    Nov 9, 2015
    Posts:
    5
    My animations start late. How can I fix this?
     
  18. FireHawkX

    FireHawkX

    Joined:
    Apr 26, 2016
    Posts:
    28
    to answer PJSkittles 1st question : your camera seems messed up... my guess is that your player script might not be attached to the camera... or the player is not added to the "public gameobject" in the camera so it follows correctly... one thing to try is to exit play mode first, then open both the scene view AND game view, select the camera and check the settings in the inspector to make sure you can see the player... and that the script camera follow is correctly attached as well as the "player target" that needs to be dragged inside the script on the camera :) -- as for your animation late... i wouldnt know where to start as its pretty impossible to troubleshoot without having access to the actual project...


    NOW for my own question : I am making an actual full commercial game (with 250 levels, 5 endless modes, 20 upgrades, etc...) I wanted to have some of the visual assets (models/environnement) from this game... i searched pretty much everywhere and it seems to be an open free liscence... meaning i can do whatever i want with it... is that correct? I wouldnt want to release my game and then get sued... ;) Thank you for your time and have a nice day!
     
  19. Ghost2656

    Ghost2656

    Joined:
    Sep 8, 2016
    Posts:
    1
    I just want to have a movement script without the animation. How much would I need to remove from the player movement script to get my desired result?
     
  20. cesarpachon_metacog

    cesarpachon_metacog

    Joined:
    Sep 7, 2016
    Posts:
    4
    hi! I completed the tutorial and it works fine when launching from the IDE, either from mac and from linux. But when I try a webgl build, it fails, displaying a in-game console saying "Argument exception: the object you want to instantiate is null". there is no more information, and in the javascript console the stack trace is not human readable. the other symptom is that the bunnies did not appear. as I said, only happens in webgl.. Screen Shot 2016-09-08 at 9.14.55 AM.png
     
  21. Spawn0208

    Spawn0208

    Joined:
    Jun 3, 2015
    Posts:
    1


    Hello @ All!
    I´m new here and i´m trying to create that shooter game with the Video Tutorial. I think my Problem is similar like Barney´s. I shoot the Zombunny a few times, an after that, the "shots" going trough the Zombunny and i can´t kill him. The Zombunny can hurt me an kill the player for a Game Over.

    Also suprising for me is, that the Game starts after the Game Over, with everything complety coded and finished, with all characters and displaying Points, which i didnt code yet. Probably i imported the finished Game somehow.
     
  22. Wolfgabe

    Wolfgabe

    Joined:
    Sep 4, 2016
    Posts:
    131
    I have been doing everything the tutorial says and everything seems to work fine so far but I am not sure on the lighting. I dragged the lights into the hierarchy like it said yet it doesnt look like what is shown in the tutorial videos




    not sure if if there is something I missed of if I did something wrong
     
  23. Wolfgabe

    Wolfgabe

    Joined:
    Sep 4, 2016
    Posts:
    131
    for some reason my zombear and hellephant spawners are not spawning anything I am not sure what I did wrong
     
  24. Wolfgabe

    Wolfgabe

    Joined:
    Sep 4, 2016
    Posts:
    131
    I really need help like bad. My lighting is off and my zombear and hellephant spawners are not working even though I did everything correctly. I have tried everything I can think but nothing works and google has failed me
     
  25. Sky1988

    Sky1988

    Joined:
    Aug 25, 2016
    Posts:
    9
    I export it as apk file, and I opened it with samsung note 5, the game doesn't have player movement controller, i can't move the character, what should i do?
     
  26. johnCordeiro

    johnCordeiro

    Joined:
    Mar 15, 2016
    Posts:
    6
    Great tutorial. I completed it using Unity 5.3.4, everything worked like a charm. Few exceptions to the Code scripts which needed to be fixed in unity 5. Mainly the Application.loadLevel line in the playerHealth which I switched to SceneManager.LoadScene(SceneManager.GetActiveScene ().buildIndex);

    Also had to load the SceneManager at the top of the script
    using UnityEngine.SceneManagement;

    the only other problem I noticed was the new event on the idle clip for the Zombunny which caused an error after the GameOver executes.

    I do have 1 question. Where is the public function PlayerHealth.RestartLevel(); being called from to restart the level after GameOver?

    Thank you
    John Cordeiro
     
  27. johnCordeiro

    johnCordeiro

    Joined:
    Mar 15, 2016
    Posts:
    6
    Added Death Particles to the Characters.

    Create a empty child object under the character and name it DeathParticles.
    Copy the DeathParticles Component from the Zombear prefab and paste it on to the newly created DeathParticles object.

    Open EnemyHealth script, after the hitParticles variable add the following line.

    ParticleSystem hitParticles; // Hit particle system reference
    ParticleSystem deathParticles; // Death particle system

    In the awake function setup the reference by adding the following line.
    deathParticles = GetComponentInChildren <ParticleSystem> ();

    Next add the following 2 lines to the Death function after the line anim.SetTrigger ("Dead");

    deathParticles.transform.position = transform.position; // Set position of particles to hit point on enemy
    deathParticles.Play(); // play death particles

    Now when enemies die they will shoot out 2 buffs of stuffing as they die.

    Hope this helps someone.

    John Cordeiro
     
  28. johnCordeiro

    johnCordeiro

    Joined:
    Mar 15, 2016
    Posts:
    6
    How do I stop all the enemies from spawning and and make them all die when the player reaches a certain score?

    Stopping the spawning seems straight forward just disable the game object that contains the EnemyManager.

    I am a little confused on how to disable all the enemies though.
    I have added the following to the ScoreManager.

    public int WinScore; // Score player must reach to advance to next level or wave.
    EnemyHealth enemyHealth; // Variable to hold EnemyHealth

    void Update ()
    {
    text.text = "Score: " + score;
    if (score >= WinScore) {


    enemyHealth.PlayerWins(); // Function to kill all enemies.

    anim.SetTrigger ("NextLevel"); // Play next level animation on HudCanvas.

    }
    }

    I have an Idea of how to proceed but wanted to get some advice first.
    In the enemyHeath I was planning on creating a new public function named PlayerWins();

    There I would basically copy the IsSinking block and add in the death animation so they enemies die and then sink.

    Any Advice is greatly appreciated.
    Thank you
    John Cordeiro
     
    patrickshyee likes this.
  29. RedDjinnPro

    RedDjinnPro

    Joined:
    Aug 13, 2013
    Posts:
    11
    Greetings all. In short, I did this tutorial when I first started learning Unity and hit a snag. Couldnt solve it. Now, after I felt much more confident I revisited it but have hit the same snag and cant find a solution.

    My zombunny wont move toward the player. It simply walks in place. I have ensured my player has been tagged as "Player" as called for in the enemymovementscript.cs and I have tried countless baking configurations. Buckner was kind enough on another site to mention the change to the step height being 0.35 but that didnt solve it. I thought maybe it was applying root motion as that has visually has the same effect as I am experiencing but that didnt work either. Lastly, I opted to use all of the provided script assets to ensure I wasnt mistyping anything and still have not gotten the little guy to follow. Anyone else having this problem? Suggestions?

    Thank you so much in advance for your time!
     
  30. gothboiclique3

    gothboiclique3

    Joined:
    Sep 21, 2016
    Posts:
    1
    Hey Guys i made the game but i dont know how to add mobile controls or a joystick?Can some body help me?Thank You!
     
  31. StacyKit10

    StacyKit10

    Joined:
    Sep 13, 2016
    Posts:
    2
    Great idea John! This came to mind:
    public class ScoreManager : MonoBehaviour
    {
    public int score;
    public bool won;
    public int winScore;

    Text text;

    void Awake ()
    {
    text = GetComponent <Text> ();
    score = 0;
    won = false;
    }

    public void ChangeScore( int change )
    {
    score += change;
    text.text = "Score: " + score;
    if ( score >= winScore )
    {
    won = true;
    }
    }

    void Update ()
    {
    // Moved to ChangeScore so it doesn't happen every frame.
    }
    }

    Note that this was also re-arch'd to implement ChangeScore as a function, rather than directly manipulating the score - that way I can do "things" on a change. I also set it this way so the score could be decreased just-in-case. I moved the code out of Update, so it's happening only when the score changes, not 30+times a second (?).

    This change also required this:
    ...private member...
    ScoreManager scoreManager;

    void Awake ()
    {
    anim = GetComponent <Animator> ();
    enemyAudio = GetComponent <AudioSource> ();
    hitParticles = GetComponentInChildren <ParticleSystem> ();
    capsuleCollider = GetComponent <CapsuleCollider> ();
    scoreManager = GameObject.Find("ScoreText").GetComponent<ScoreManager>();

    currentHealth = startingHealth;
    }


    void Update ()
    {
    if(isSinking)
    {
    transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
    }

    if (scoreManager.won && isDead == false )
    {
    Death();
    }
    }

    This works for me, and I think is somewhat robust. The call to Find is pretty expensive, but I'm thinking it's less expensive than the updating of the text every frame (though that could be fixed a different way). You could re-build my changes to include more statics, if you prefer, of course! What ever best works for you.

    Also make sure you add currentHealth = 0; in the Death function. So that EnemyMovement works properly.

    Note that this is missing the changes to the spawing of enemies, who will continue to spawn, and promptly die.

    I think these changes "fit" the original design pretty well.

    Good luck!
    Q
     
    Last edited: Sep 25, 2016
    johnCordeiro likes this.
  32. hockeym4n

    hockeym4n

    Joined:
    Sep 26, 2016
    Posts:
    1
    Can someone help me fix this error please
     

    Attached Files:

  33. qwert024

    qwert024

    Joined:
    Oct 21, 2015
    Posts:
    43
    Hello, I have the same problems. :(
    I set "Interruption Source" to "Next State", and now it does play Move animation when I move the player.
    I wonder whether it is a correct way to fix my problem.
    However, the problem that Idle animation gets stuck still exists -- if Idle animation finishes and I'm not moving the player, it gets stuck and no animation is shown.
    Thanks for any help!
    upload_2016-9-27_11-45-25.png
     
  34. CoranTheSilver

    CoranTheSilver

    Joined:
    Sep 25, 2016
    Posts:
    5
    Did a bunch of searching to figure out why my character wasn't moving at all after the end of lesson two and finally figured out the solution. Somehow I forgot to attach the script to the player! I simply dragged the PlayerMovement Script from the project file to the hierarchy for player and presto! Just in case someone else ran into this. Also, thanks to all of the people who watch this forum and try their best to answer some of the crazy scripting issues people run into. You guys are great.
     
  35. CoranTheSilver

    CoranTheSilver

    Joined:
    Sep 25, 2016
    Posts:
    5
  36. BlackAceZero777

    BlackAceZero777

    Joined:
    Jul 27, 2016
    Posts:
    24
    Hello again, I have finished the survival shooter and I am trying to post it to a certain site but I need to convert it to either an EXE or html5 folder and need help with how to convert it.
     
  37. VitaminK

    VitaminK

    Joined:
    Sep 30, 2016
    Posts:
    3
    On "Creating Enemy #1", Zombunny does not seek out player. It stands in the same place continuously performing the walk animation. I've restarted this section of the Tutorial 3 times. Tried copying the code over exact. Using Unity site tutorial + transcript + updated pdf. Tried all the responses I've found on this forum (and youtube) including making sure Floor is set to Static, making sure player is tagged as "Player", using "GameObject.Find" instead of the original code suggested, nothing seems to work.

    The player can push around the Zombunny but it doesn't move and continues to performing walk animation.

    Using Unity 5.4.1f1. I have seen this issue in several versions but none so far directly for 5.4.1 posted yet. Here's a couple screens and the copied over code;

    Screenshot - http://i65.tinypic.com/34zf66w.jpg
    Screenshot - http://oi66.tinypic.com/mtnznp.jpg

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class EnemyMovement : MonoBehaviour
    5. {
    6.     Transform player;               // Reference to the player's position.
    7.     PlayerHealth playerHealth;      // Reference to the player's health.
    8.     EnemyHealth enemyHealth;        // Reference to this enemy's health.
    9.     NavMeshAgent nav;               // Reference to the nav mesh agent.
    10.  
    11.  
    12.     void Awake()
    13.     {
    14.         // Set up the references.
    15.         player = GameObject.FindGameObjectWithTag("Player").transform;
    16.         playerHealth = player.GetComponent<PlayerHealth>();
    17.         enemyHealth = GetComponent<EnemyHealth>();
    18.         nav = GetComponent<NavMeshAgent>();
    19.     }
    20.  
    21.  
    22.     void Update()
    23.     {
    24.         // If the enemy and the player have health left...
    25.         if (enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
    26.         {
    27.             // ... set the destination of the nav mesh agent to the player.
    28.             nav.SetDestination(player.position);
    29.         }
    30.         // Otherwise...
    31.         else
    32.         {
    33.             // ... disable the nav mesh agent.
    34.             nav.enabled = false;
    35.         }
    36.     }
    37. }
    If there's any other info I can give to help solve this let me know!
     
  38. ABeardedWonder

    ABeardedWonder

    Joined:
    Oct 4, 2016
    Posts:
    8

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

    Hey all, ive read about 4-5 pages and seen issues with stage 2- movement pop up alot but nothing i tried could fix it.

    Above you can see my code (i swear i've checked it near word for word but cant see the forest for the trees) and above that the screenshots of the errors.

    If i copy and paste the code from the tutorial page i am able to move, BUT i still get loads of errors pop up regardless. So at least i know my movement issue (which is my main concern anyway) is a problem in my script.

    Ive been looking at it for so long its all blurred into one thing, anyone able to spot what i can not?
     
  39. original-name

    original-name

    Joined:
    Aug 5, 2016
    Posts:
    3
    From what I can gather, your shooting script is on the player game object instead of the gun and the awake method in your movement script needs to be Awake with an uppercase A.

    Edit: shooting script goes on the gun, not gun barrel
     
    Last edited: Oct 7, 2016
  40. ABeardedWonder

    ABeardedWonder

    Joined:
    Oct 4, 2016
    Posts:
    8
    Ah, not on the shooting bit yet but thanks for the heads up, moved that script over.#


    And movement works now. I can not BELIEVE thats what caused my movement problems

    I'm still getting errors about line renderer, but so far the tutorial hasnt told me to add line renderer so im assuming seeing as it moves as it should be, i'm ignoring it for now
     
  41. Legendmir

    Legendmir

    Joined:
    Oct 1, 2016
    Posts:
    8
    Cam issue.png

    I noticed someone else was having this problem too.

    I face palmed when i realized what i did wrong.

    In the camera follow script check the void start function thoroughly. A small spelling mistake in there caused this for me.
     
  42. Gold_Z

    Gold_Z

    Joined:
    Oct 12, 2016
    Posts:
    1
    So, I am the only one that downloaded the asset and was not able to find both the Zombear and the Hellephant prefabs? (and by that I mean the one that are edited in the tutorial, not those the the Completed folder)
     
  43. BlackAceZero777

    BlackAceZero777

    Joined:
    Jul 27, 2016
    Posts:
    24
    Can anyone help me with this?
     
  44. nwzebra

    nwzebra

    Joined:
    Dec 4, 2015
    Posts:
    16
    No, I believe that this is a problem with the latest release of the assets/and or version 5.4.1f. I have several different versions of the Survival Shooter assets and only the latest one doesn't have the Hellephant and Zombear prefabs. I also have students that only have version 5.3 and they have the prefabs. I have yet to get to this point with my students, but I'll be tempted to grab the completed asset version and swap out the right components.
     
  45. CGinSeattle

    CGinSeattle

    Joined:
    Jul 20, 2013
    Posts:
    15
  46. patrickshyee

    patrickshyee

    Joined:
    Apr 25, 2015
    Posts:
    4
    If you are running the tutorials, you are creating the floor layer. Please replay the environment tutorial.
     
  47. patrickshyee

    patrickshyee

    Joined:
    Apr 25, 2015
    Posts:
    4
    There is a script in the Completed folder in the there Script/Manager folder, I would direct you there to the PauseManager.cs for some guidance.
     
  48. patrickshyee

    patrickshyee

    Joined:
    Apr 25, 2015
    Posts:
    4
    Hello everyone,
    I have done the whole tutorial and found it helpful, but for the last phase - Game Over. It won't reload my scene that I created, it keeps on loading there completed scene.
     
  49. patrickshyee

    patrickshyee

    Joined:
    Apr 25, 2015
    Posts:
    4
    I figure it out in the SceneManager.LoadScene() in the PlayerHealth.cs, change the '0' to '1'.
     
  50. nwzebra

    nwzebra

    Joined:
    Dec 4, 2015
    Posts:
    16
    Actually a better solution is to go Build Settings, uncheck the Complete Scene and add the current scene.