Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Survival Shooter tutorial issues

Discussion in 'Community Learning & Teaching' started by Lana L., Jan 26, 2015.

Thread Status:
Not open for further replies.
  1. Lana L.

    Lana L.

    Joined:
    Jan 23, 2015
    Posts:
    3
    So I've been working on the survival shooter tutorial they've got up on the learn section of the site.
    It's been going well, everything works... but it seems like the ray cast has some accuracy problems when I'm trying to hit the capsule collider from certain angles. It always registers a hit when I aim toward the base of the enemy. But, if I aim for the head it only registers a hit from certain angles. Additionally, the effect that shows up on the enemy where it was hit doesn't appear on the top/head of the enemy, even when that area is hit (unless he's bent about to die, ha ha). The capsule collider is set up exactly as specified in the tutorial. I even tried adding a huge one over the head just to see what would happen, and it still has similar issues.

    Shooting next to the enemy like this is where it's not registering hits to the head/upper part of the enemy at all. It still hits when I aim lower on the enemy, but if I aim for the head, the beam flies right behind the head and registers the hit somewhere in the distance, like the train or car or whatever's there. He's falling over to die in this picture..

    zombunny2.jpg

    Shooting up or down to the enemy as in the following picture works ok. It hits when I aim at the head, but the effect still doesn't show up over the head. I shot up on the top of his head for this picture:

    zombunny.jpg

    Am I missing something really obvious here... or is this normal? Some issue with how we're seeing what's really happening through the camera? It makes game play pretty frustrating if you're aiming at the top of the bunny and it doesn't register the hit. :\ Is there a solution for this? I'm a unity newbie, so please excuse me if this is painfully obvious to you more experienced people. :)

    Thanks for your advice!

    EDIT: I think I get why this works this way. As I understand, the ray is being cast out forward from the tip of the gun. The camera has a different viewpoint and it might look like it should hit from this point of view, but not from where it's actually being cast. Hmmm..
     
    Last edited: Jan 26, 2015
  2. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    792
    Hi Lana

    Thanks for your post on Survival Shooter. For simplicity we have indeed taken the approach that the ray shoots forward from the gun parallel to the floor. We did this so as to keep things simple for the training day (the original use of this project) and so that it's not too much complexity for the beginner.

    To add the functionality you have it makes sense to add an else to the point at which we shoot the ray and draw the line, instead of simply using the point on the collider, you could use the ray drawn from the camera to find the point on the collider - or under the mouse position. so basically it would allow you to aim up.

    Anyone up for writing an example of this for Lana? there's a challenge! I would but am super busy right now hoping someone here can dive in and show you what I mean - or maybe you already can do it yourself! either way have fun :)

    Will
     
  3. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    Check out the scripting reference on Raycasting: http://docs.unity3d.com/ScriptReference/Physics.Raycast.html

    If you want to cast the ray from your mouse position, you'd do:

    Ray ray = Camera.main.ScreenPointToRay(input.mouseposition);

    This will cast a ray where your mouse cursor is.

    If you want to cast a ray from your viewport (game view) and have it centered or something on the screen, you'd do:

    Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));

    the 0.5 values in the vector3 specify the center on the horizontal axis (x) and the vertical axis (y)
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    It's worth noting that there is a Debug.DrawRay method. This lets you see what is happening.
     
    theANMATOR2b likes this.
  5. tgraef

    tgraef

    Joined:
    Feb 9, 2015
    Posts:
    11
    I am having a different issue with this tutorial. Since it is in the same program I thought I would just put the question in here. I have completed the tutorial and everything runs like it is supposed to in Unity. When I build and run the game as a web player or as an .exe, I do not ever see the "Score" GUI or the "Game Over" animation GUI. Is there some type of compatibility editing to those pieces of the HUD that I need to perform to make it work outside of Unity?

    Inside Unity
    upload_2015-2-9_7-41-14.png

    Outside Unity
    upload_2015-2-9_7-43-10.png
     
  6. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    tgraef: You should check your anchors in your anchors and presets menu.

    I would suggest you have the score anchored to the top of the canvas.

    There are both documentation pages and at least one live session on resolution independence, which might help. It's clear your aspect ratio changes between your editor view and your deployed game.

    On thing that might help would be to create an aspect ratio / resolution preset in the game view and test that in the editor.
     
  7. joann24

    joann24

    Joined:
    Feb 24, 2015
    Posts:
    2
    Hello!

    I have the same issue as tgraef has and i made sure that the score is anchored on the top of the canvas..

    And the Game Over part is also still not working outside the Unity program (as an .exe file)
     

    Attached Files:

  8. joann24

    joann24

    Joined:
    Feb 24, 2015
    Posts:
    2
    upload_2015-2-24_12-27-47.png

    I sorted the problem out! When you press "Build", make sure you delete the scenes in build that appear there and then press the button "Add Current". Only after that press "Build" and voila!
     
  9. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yes, the build settings window will build only the scenes you have added to it - with one exception (iirc...). If my memory serves, only if you have NO scenes in the build settings window at all, and try to build, Unity will use the current scene, otherwise it will only use the scenes in the build window (which makes sense - as it's only building the scenes you are asking it to!). If you don't have your current build in the build settings window, it won't be built!
     
  10. AK123

    AK123

    Joined:
    Apr 9, 2015
    Posts:
    2
    At the end of the tutorial (unity 5) the game does restart but it never shows the "game over" part. There are two reload or restart games in the code. One is on the GameOverManager script and the other is on the PlayerHealth script. Science the animation isn't running, I have to assume that its still using the player health restart. I tried removing / commenting it out and it did not use the game over manager restart.

    Also, I have the issue where the screen gets darker every time it restarts. if you play the game to death and end it, then the game window goes completely black except you and the zombunny. to get it back you have to disable and re-enable the environment component. but how do we fix this so that when people are playing it, it just works.
     
    neoedgar likes this.
  11. sergio32

    sergio32

    Joined:
    Apr 27, 2015
    Posts:
    1
    I have a problem with the script completed in the second part, I copied it exactly but I'm still getting 4 or 5 errors.
     
  12. neoedgar

    neoedgar

    Joined:
    Apr 15, 2015
    Posts:
    1
    I have the same problem :(
     
  13. Simpso

    Simpso

    Joined:
    Apr 20, 2015
    Posts:
    158
    Hey, can you copy in your code and mark out the errors. Will try to help you .
     
  14. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    Hey guys,

    @AK123 @neoedgar I'm unable to say for sure but this could potentially be a problem with Unity rather than the project. There is a screen fader gameobject which is part of the UI. It could be a problem with the code controlling that. To determine if this is the case, keep an eye on the alpha level of the screen fader's image. If it is consistently getting higher then the problem is in the code controlling it, I'll take a look at it and hopefully fix it. If the alpha level is staying consistent then it could be a problem with Unity and we'd really appreciate you sending us a bug report.

    Thanks.
     
  15. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    617
    Is anyone else having problems with the navmesh agents?
     
  16. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    What sort of trouble are you having with the Nav Mesh Agents?
     
  17. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Hello! Sorry to be a pain, but this thread is drawing attention away from the official Survival Shooter Q&A thread:
    http://forum.unity3d.com/threads/survival-shooter-q-a.313934/

    I'm closing this thread, as the OP has been answered.

    Can you please read the FAQ in the OP of the official thread, then browse the thread for additional answers. If at this point your question is still unanswered, please post there.
     
Thread Status:
Not open for further replies.