Search Unity

Let's Try Assignments Q&A

Discussion in 'Community Learning & Teaching' started by Matthew-Schell, Aug 16, 2016.

  1. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    This is the official thread for discussion, issues and Q&A for the Let's Try tutorial assignments.

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

    The Let's Try series is a set of tutorials on our Learn Site:
    http://www.unity3d.com/learn/tutorials/lets-try


    In our Let's Try series of tutorials we will explore popular game mechanics in standalone assignments. Instead of creating an entire game, we will focus on a single mechanic and the techniques needed to implement it.

    Post your questions and the team and we will try to help you out!

    IMPORTANT:
    If you want to post a script you are having trouble with, please post the whole script that is throwing an error using proper code formatting detailed in the thread below, a screenshot of the public variables in the inspector and copy and paste the error message from the console if there is one.

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

    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.
     
    Deleted User, OboShape and Gametyme like this.
  2. thumbzofsteel

    thumbzofsteel

    Joined:
    Apr 19, 2016
    Posts:
    2
    It seems the free download asset pack opens in Unity without a download button.
     
  3. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    is that the web link for the asset store showing Open in Unity? as it wont give option for download until you have the asset store open within the editor. (i believe)

    Should ask you to download once you opened it in Unity, then once downloaded the button will change to Import.
    or, with Unity editor open, go to Window > Asset Store and search for 'Lets try' from Unity Technologies and it should download and Import from there.
     
  4. Deleted User

    Deleted User

    Guest

    Thank you! :)

    I had a download button. Maybe you need to wait that the window is fully loaded?
     
    Last edited by a moderator: Aug 17, 2016
  5. thumbzofsteel

    thumbzofsteel

    Joined:
    Apr 19, 2016
    Posts:
    2
    Upgrading from 5.3 to 5.4 fixed it.
     
  6. DatGuyPotato

    DatGuyPotato

    Joined:
    Jul 14, 2016
    Posts:
    8
    i keep getting errors on the crossplatforminput

    should i do something about or should i leave it there?
     
  7. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    That will be for the FPS controller. You could try re-importing the 'Characters' package from Assets > Import Package.
     
  8. Mortzart

    Mortzart

    Joined:
    Aug 30, 2016
    Posts:
    1
    I am not able to access Psychics class at all (Raycast shooting).

    It just gives me Compiler errors, it worked in earlier tutorials.

    Edit: Just realised i misspelled physics... Problem solved. I am dumb.
     
  9. lucadome

    lucadome

    Joined:
    Jan 5, 2014
    Posts:
    1
    If i shot down my shot stop going on and doesn't hit the floor,it returns to the player in the opposite verse, can you help me??
    Immagine.png
    Immagine.png
    Immagine2.png Immagine3.png
     
    Last edited: Sep 23, 2016
  10. destiny0114

    destiny0114

    Joined:
    Sep 18, 2016
    Posts:
    2
  11. Rustygear3

    Rustygear3

    Joined:
    Oct 1, 2016
    Posts:
    4
    It seems that the grenade mesh is missing from the asset package.
     
  12. Dustiknux

    Dustiknux

    Joined:
    Oct 17, 2016
    Posts:
    1
    Hi, I'm having trouble dragging the GunEnd game object into the Gun End field in the Raycastshoot (script) section of the inspector menu as the Gun End field isn't there! Help! :(
     
    Psyhotick likes this.
  13. murphjac

    murphjac

    Joined:
    Oct 17, 2016
    Posts:
    1
    It seems that the raycast is interacting with the character's collider. Look at the Character Controller component for the FPSController GameObject in the Scene:

    collider_bug_screen.png

    If you want to see this in-game, alter your RayCastShoot script to redraw laserLine every update (so you won't have to switch back to the Game view and click to see the results). For example, I changed the first few lines of the Update() function in RayCastShoot.cs to this:

    collider_bug_screen_2.png

    If you play with the Radius, Height, or Center options on the Character Controller, you can see when the laserLine starts/stops interacting with the character's collider.

    The fix is simple: Change the Layer of the FPSController to "IgnoreRaycast." When the dialog asks you if you want to change the children, say No. It isn't necessary to change the child objects to fix this issue.

    Side note: I don't yet understand why the ray is being cast back into the camera when this interaction happens. There may be some underlying issue that I haven't discovered yet, but ignoring raycasts onto the character's collider seems to solve the obvious problem.

    Hope that helps!
     
    Matthew-Schell likes this.
  14. kdhhhh

    kdhhhh

    Joined:
    Oct 27, 2016
    Posts:
    1
    Hi , I want to go to next level? or next stage...But how..? Please tell me. Or Originally it have been only one stage?
     
  15. DennyBoy

    DennyBoy

    Joined:
    Jan 19, 2016
    Posts:
    34
    How do i make the camera move when the mouse is moving?
     
  16. MHUnity

    MHUnity

    Joined:
    Jan 11, 2015
    Posts:
    21
  17. MHUnity

    MHUnity

    Joined:
    Jan 11, 2015
    Posts:
    21
    Matthew-Schell likes this.
  18. DennyBoy

    DennyBoy

    Joined:
    Jan 19, 2016
    Posts:
    34
  19. TwistedN1

    TwistedN1

    Joined:
    Dec 31, 2016
    Posts:
    1
    I'm starting the tutorial and when told to put the C# script into the gun prephab it says
    "Can't add script component 'RaycastShoot' because the script class cannot be found"
    what can I do?
     
  20. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    Please check to make sure that the gunEnd variable has the 'public' access modifier and that your script is compiling without errors.
     
  21. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    There is only one stage. It's a tutorial not a game.
     
  22. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    Make sure that your script file and C# class have matching names.
     
  23. Shindy117

    Shindy117

    Joined:
    Sep 6, 2016
    Posts:
    1
    Hello I am having a issue with the assignment. I am using the code for my game project for school.

    My issue is when you look down. The Raycast shoots back towards the camera instead of straight ahead.
    I set up my scripts and everything just like the tutorial. The game works fine but when I look down from a FPS perceptive
    it looks like the raycast isn't going all the way forward just stops half way. I looked at this in the scene view and the Ray shot shoots back towards the camera.

    Please help...
     
  24. MHUnity

    MHUnity

    Joined:
    Jan 11, 2015
    Posts:
    21
    Shindy, if you read the forum posts above yours specifically read the post by murphjac which sounds like the issue you're having.
     
    Matthew-Schell likes this.
  25. MHUnity

    MHUnity

    Joined:
    Jan 11, 2015
    Posts:
    21
    Your HTTPS connection is insecure and unsafe. I would highly recommend hosting your images somewhere else such as https://httpsimage.com/ (although there are many, many choices).
     
  26. Nerper

    Nerper

    Joined:
    Feb 19, 2017
    Posts:
    1
    Hey, I just got Unity and thought this game was cool, so i tried it out. Turns out he tutorial doesn't tell you how to 'expand' a C# script so you can drag things into it. I was wondering how to do it.
     
  27. MHUnity

    MHUnity

    Joined:
    Jan 11, 2015
    Posts:
    21
    Scripting doesn't specifically work like that. You would need to declare a public object reference in the script and then drag and drop items in the Game Inspector in Unity onto the SCcript file found on the object.

    Quick example:

    In a script add a line underneath your class declaration and before your method calls:

    public GameObject $gobject; within the class.

    then save, And open your object in the Unity GUI, and add this script to that object, by dragging and dropping. Then you can select the other game object you want `$gobject` to reference and drag it into the script file area in the Inspector. Perhaps watching some Unity Videos will show you the areas to look at for doing this.
     
  28. KDB44

    KDB44

    Joined:
    Feb 12, 2017
    Posts:
    5
    Hi,

    I recently download the Let's try Shooter pack and that I get a warning message saying that The Referenced script on this behavior is missing (game object 'Gun' ). I think is is why I cannot fire the gun. Any help?
     
    leekasong likes this.
  29. doriri

    doriri

    Joined:
    Mar 1, 2017
    Posts:
    1
    I get the same warning message even if I try the completed scene. Updating Unity didn't solve the problem.
     
  30. Zathoxic

    Zathoxic

    Joined:
    Mar 3, 2017
    Posts:
    1
    Hi there!

    I've watched your video and followed each step, but for some reason the shot goes to the right and up of the player... I've gone through the code a few more times but can't seem to find whats wrong :( Any suggestions?
     
  31. xox_slendy

    xox_slendy

    Joined:
    Mar 5, 2017
    Posts:
    1
    I don't want the line Rendered (like in the video) in my game. What should i do
     
  32. Tazling

    Tazling

    Joined:
    Jan 26, 2017
    Posts:
    25
    OSX El Capitan, Unity 5.5, Steam version

    Ditto here, I think the completed scene is broken. When I try to fire the gun, nothing happens and I get the error message reported by KDB44, above. Pity, as I was interested in this tutorial. But if it's broken, probably beyond my skills to fix it. Does anyone know of another tutorial about FPS that is not broken?

    ANSWER: If the name of the script does not EXACTLY match the name of the class defined in the script -- and this includes case -- then you get this error message. It is not a very helpful error message. "Class name does not match file name" would be more helpful. In the case of this demo, as shipped the name of the class is RaycastShootComplete but the name of the script is RayCastShootComplete. Note the C in "cast" is lower case in the class name and upper case in the script name. I changed the class name so this letter is upper case. Now Unity is happy about associating the script with the Gun object, but the gun still does not fire properly so we are not done yet.

    I do get the firing sound effect, kind of a phaser noise, but an error is displayed at bottom of UI, "the variable gunEnd of RayCastShootComplete has not been assigned." Looking in the script I see that it declares a public Transform gunEnd. And sure enough if you look at the Gun object in Inspector, its associated script wants that public variable gunEnd, which is not filled in. Unpacking the object further in Hierarchy, I find that its child ShooterFPSWeapon has a child GunEnd which is a Transform. So at a wild guess (I am just a n00b at Unity but have several decades of coding experience) I drag the GunEnd Transform into the script variable box for gunEnd and it is accepted.

    I can now fire the gun and hit the purple cubes, knocking them off their stands.

    NOTE to UNITY staff: kind of a booboo, folks, to package up a tutorial (aimed at beginners!) with missing parts, typos, incomplete configurations. I know it's a real challenge to produce perfect releases, but OTOH it's worth extra effort. 'Cos it's bad PR for the app if the beginner tutorials require adventurous hacking just to get them into a usable state. It's particularly essential to test a tutorial release before it gets posted for download. I was able to find my way through this broken package only because of long hacking experience plus the good fortune that the breakage was fairly simple. If it had been a more sophisticated error :) I would have given up, and would not now be able to learn about fps physics in Unity.

    Advanced tutorials, now those might be deliberately released with bugs "as an exercise for the reader". But the beginner level ones really ought to work exactly as the video/article says they should, otherwise n00bies tend to panic.
     
    Last edited: Mar 10, 2017
  33. Saucyminator

    Saucyminator

    Joined:
    Nov 23, 2015
    Posts:
    61
  34. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    hey, sorry, this one got delayed and I don't have a date for when it will be out, the script is written and ready to be recorded. I'll post the link here when it's ready.
     
    muzboz and Deleted User like this.
  35. Saucyminator

    Saucyminator

    Joined:
    Nov 23, 2015
    Posts:
    61
    No worries, I thought it had been removed. Thanks for all the tutorials so far and have a nice weekend!
     
    Matthew-Schell likes this.
  36. alv16106

    alv16106

    Joined:
    May 24, 2017
    Posts:
    1
    Hey! I keep shooting myself as lucodome said, I tried the solution of changing the player layer. It works fine, but if I want to make a game where I need to shoot another player how do I get it to work given that his layer will have to be "IgnoreRayCast" too?
     
  37. Podpryadok

    Podpryadok

    Joined:
    May 28, 2017
    Posts:
    1
    Hey. I had a problem with the visualization of the line. Firstly, I have a newer version and because of this the component editor looks different, and secondly the line appears in the middle of the room. Help please adjust it in a new editor. Sorry for the grammar, I use Google Translate))
    http://prntscr.com/fd1ary
     
  38. Matthew-Schell

    Matthew-Schell

    Joined:
    Oct 1, 2014
    Posts:
    238
    There are a few ways to deal with this, you could try adjusting the player collider shape or position, or you could make sure that the raycast cannot hit this player's layer. If you wanted multiple players you would need to use multiple layers and a layer mask specifying which layer which player could shoot.
     
  39. tejo240

    tejo240

    Joined:
    May 31, 2017
    Posts:
    2
    I fixed it creating a new layer (layer number 9 called ignoreMyRaycast). I changed the script a bit. leave every line as it is but add this two lines under Raycast hit:

    int layerMask = 1 << 9;

    layerMask = ~layerMask;

    and change the if statement condition with this one.

    if (Physics.Raycast(rayOrigin,fpsCam.transform.forward,out hit,weaponRange,layerMask)){
    ...
    }

    that should make your raycasts register collisiones in every layer except layer 9.
     
  40. Siridivi

    Siridivi

    Joined:
    Dec 9, 2014
    Posts:
    1
    Very good tutorial. I like just doing the barebones of a single concept. The only thing I didn't understand is how the red dot gets tied to the raycast hit? Nowhere in the tutorial do we associate the image with anything so you lost me there.
     
  41. JacekMackiewicz

    JacekMackiewicz

    Unity Technologies

    Joined:
    Jul 5, 2017
    Posts:
    34
    Hi Sirdivi,
    The "red dot" in the middle of the screen isn't actually tied to the raycast at all!
    Since the raycast always shoots out from the middle of the screen, we can place a red square in the middle of our canvas to act as a targeting reticule. This way when we move our camera around, the red square will always remain right in the middle, and show where the raycast will end up.
     
  42. Psyhotick

    Psyhotick

    Joined:
    Sep 11, 2017
    Posts:
    1
    same thing...
    upload_2017-9-11_19-26-40.png
     
    Last edited: Sep 11, 2017
  43. ALDUIIN

    ALDUIIN

    Joined:
    Oct 15, 2017
    Posts:
    1
    I would like to Instantiate my bullet to the center of the screen, i'm using TPS camera, help please.
    I'm becoming crazy with this.
     
  44. jnmnmz

    jnmnmz

    Joined:
    Apr 25, 2017
    Posts:
    2
    Why are Unity tutorials so bad and scattered? They do not feel like doing the things? :(
     
  45. Elyndrium

    Elyndrium

    Joined:
    Dec 20, 2017
    Posts:
    1
    I have azerty keyboard and so I would like to change game controls from wasd to zqsd... Help please !

    Edit:

    Also have some problems with my teleportation system:

    transform.position = new Vector3(0, -10, -45);

    When I put another command like that:

    transform.position = new Vector3(0, -10, -45);
    lifepoint = lifepoint + 1000 // HERE

    The second one works, so there is probable a problem with the line af code...
    Excuse me if it's obvious, I'm new to unity...
    And also excuse me for my english I'm french...
     
    Last edited: Dec 23, 2017
  46. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Just had a look at your ''Let's Try Game Dev: Shooting via Raycasting'' excellent video I just wonder if this would eork on s Spherical surface and if you would have to add the planets gravity to the bullet/lazer e.t.c for it to be accurate if the game is on a sphere?
     
  47. Tigersong

    Tigersong

    Joined:
    Aug 11, 2014
    Posts:
    73
    Hello. I'm doing the Breakout tutorial and have an error in the paddle script (unexpected symbol: xPos at 15, 37).

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Paddle : MonoBehaviour {
    6.  
    7.     public float paddleSpeed = 1f;
    8.  
    9.     private Vector3 playerPos = new Vector3(0, -9.5f, 0);
    10.  
    11.     // Update is called once per frame
    12.     void Update () {
    13.  
    14.     float xPos = transform.position.x + (Input.GetAxis("Horizontal") * paddleSpeed);
    15. playerPos = new Vector3 (Mathf.Clamp xPos, -8f, 8f), -9.5f, 0f);
    16.         transform.position = playerPos;
    17.     }
    18. }
    It's probably a simple error on my part. Any help is appreciated!
    It was a simple error- a missing (
     
    Last edited: May 25, 2018
  48. tazshelby2016

    tazshelby2016

    Joined:
    May 29, 2018
    Posts:
    3
    I'm getting the debug message
    NullReferenceException: Object reference not set to an instance of an object

    for
    Code (CSharp):
    1. Vector3 rayOrigin = FirstPersonCharacter.ViewportToWorldPoint (new Vector3 (.5f, .5f, 0));
     
    mal123smoke likes this.
  49. kraxa

    kraxa

    Joined:
    Jul 15, 2018
    Posts:
    1
    How to change the color of the laser ???
     
  50. muzboz

    muzboz

    Joined:
    Aug 8, 2012
    Posts:
    110
    I am also keen to go thru the PROJECTILES tutorial that was supposed to follow this one...? :)

    As it seemed like a nice progression on the way to the the ABILITY SYSTEMS WITH SCRIPTABLE OBJECTS tutorial.

    Shall try to just skip ahead for now using the Completed Project code...