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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Space Shooter Tutorial Q&A

Discussion in 'Community Learning & Teaching' started by Adam-Buckner, Mar 26, 2015.

  1. xr0m

    xr0m

    Joined:
    Sep 21, 2015
    Posts:
    4
    Why do you use IEnumerator and yield return instead of function Update?
    For example:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class GameController : MonoBehaviour {
    5.  
    6.     public GameObject hazard;
    7.     public Vector3 spawnValue;
    8.     public int hazardCount;
    9.     public float maxSpawnWait;
    10.     public float startWait;
    11.     public float waveWait;
    12.  
    13.     private float nextHazard;
    14.     private int hazardCounter;
    15.  
    16.     void Start ()
    17.     {
    18.         nextHazard = startWait;
    19.         hazardCounter = hazardCount;
    20.     }
    21.  
    22.     void SpawnVaves ()
    23.     {
    24.         Vector3 spawnPosition = new Vector3 (Random.Range(-spawnValue.x, spawnValue.x), spawnValue.y, spawnValue.z);
    25.         Quaternion spawnRotation = Quaternion.identity;
    26.         Instantiate (hazard, spawnPosition, spawnRotation);
    27.     }
    28.  
    29.     void Update()
    30.     {
    31.         if (Time.time > nextHazard)
    32.         {
    33.             SpawnVaves ();
    34.             --hazardCounter;
    35.  
    36.             if (hazardCounter > 0)
    37.             {
    38.                 nextHazard = Time.time + Random.Range(0.15f, maxSpawnWait); //instead of the static spawn wait
    39.             }
    40.             else
    41.             {
    42.                 nextHazard = Time.time + waveWait;
    43.                 hazardCounter = hazardCount;
    44.             }
    45.         }
    46.     }
    47. }
     
  2. daboyzrule

    daboyzrule

    Joined:
    Sep 24, 2015
    Posts:
    3
    Hello Adam,
    I seem to be having a problem with my player ship. I have done the entire tutorial up to Audio without problems. But when I opened up Unity and my Project and Scene to finish off the game, my player would not move or shoot the shots. I definitely saved last time a closed the program. I rechecked everything, the tutorials, my scripts and everything else in unity and I cannot find a problem. Everything else is working apart from the fact I can not control the ship. There are no errors displayed in the console.

    Thanks
     
  3. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    If you are following the project from the "Learn" site (http://unity3d.com/learn/tutorials/projects/space-shooter/creating-shots?playlist=17147) the scripts are attached to the lesson page, so you can quickly check your code if you don't want to re-watch the video from the beginning and check against the lesson.
     
    JaxD likes this.
  4. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    A couple of reasons:

    1) That code hammers our game every frame to test against Time.time. With a Coroutine, the code simply pauses and picks up where it left off. It's like having an update that doesn't update every frame! It only updates when we want it to.

    Code (CSharp):
    1.     IEnumerator ControlSomethingLikeASonarPing()
    2.     {        while(true)
    3.         {
    4.             DoSomethingLikeSendASonarPing();            }
    5.             yield return new WaitForSeconds(sonarPingTimeOrOneSecond);
    6.         }
    7.     }
    With that code, you can simple send a sonar ping every second... or whatever time you want to assign to sonarPingTime. It's a lot like:
    Code (CSharp):
    1. void Update ()
    2. {
    3.    DoSomethingLikeSendASonarPing();
    4. }
    ... except it doesn't run every frame - just when we specify it to on a regular basis.

    2) Simpler more easy to read code.

    Code (CSharp):
    1. public float sonarPingTime;
    2.  
    3.     IEnumerator SonarPing()
    4.     {        while(true)
    5.         {
    6.             SendASonarPing();
    7.             yield return new WaitForSeconds(sonarPingTime);
    8.         }
    9.     }
    ... is far easier to read and write than:

    Code (CSharp):
    1. public float sonarPingTime;
    2.  
    3. private float nextSonarPing;
    4.  
    5.     void Update()
    6.     {
    7.         if (Time.time > nextSonarPing)
    8.         {
    9.                SendASonarPing();
    10.                 nextSonarPing= Time.time + sonarPingTime;
    11.         }
    12.     }
    13.  
    Also - it contains the code.

    Update could get very cluttered if absolutely everything was run and managed through Update(); This way, we have all our code tucked into SpawnWaves() or SonarPing().

    Does this make sense?
     
  5. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    No errors? Nothing at all? And no numbers have been juggled or lost? Have you checked things like "speed" on the player, and make sure it's not set to 0?
     
  6. xr0m

    xr0m

    Joined:
    Sep 21, 2015
    Posts:
    4
    Thank you very much, this is almost clear :)
    However: WaitForSeconds checks each time quantum if the time has come, it's not like Update with if? WaitForSeconds uses the engine main time or OS scheduling?

    Hmm.. I think that I understood. The coroutine creates an another thread. This reduces the load on Update, isn't it?
     
    Last edited: Sep 24, 2015
  7. JaxD

    JaxD

    Joined:
    Sep 18, 2015
    Posts:
    7
    I do check the script but they seem to be incompatible with the new Unity version? I get errors when using the lines in the scripts on the learn site.

    Code (CSharp):
    1. rigidbody.velocity = transform.forward * speed;
    This code work for me provided by guys in the comments, they claim it's the updated version for the new Unity version.

    Code (CSharp):
    1. GetComponent<Rigidbody>().velocity = transform.forward * speed;
    From my understanding, it has something to do with accessing the component in the new version. I have seen this syntax used in other tutorial videos in the Unity Tutorials section. Please correct me if I'm wrong.
     
  8. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yes, that is correct. Please check the FAQ in the original post on this thread and make sure Annotations are ON when watching the videos.
     
    JaxD likes this.
  9. xr0m

    xr0m

    Joined:
    Sep 21, 2015
    Posts:
    4
    Hello Adam,
    Can you explain me, please, why is the audio source weapon_player added to Player and not to Bolt on the similarity of explosions? To show how to use the sound programmatically?
     
  10. Deleted User

    Deleted User

    Guest

    I'm pretty new to Unity and learning how to make my first game. I'm having problems scripting and for some reason its not working for me. I don't know what I'm doing wrong, and its really frustrating. I'm hoping i can get like advice on how to do this. Thank you!
     
  11. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    In general, you want the sound of the shot to be playing from the muzzle or point that the weapon is firing. This makes little or no difference in this project, but let's say you have a gun that shoots bullets, and the shot had the shooting sound. It will take a moment for the shot to play... and as the bullet leaves the gun, the shot sound would travel with it - away from the gun, taking the gun sound with it. If you want the bullet to make a hissing or zipping sound, put THAT sound on the bullet. Leave the gun sound on the gun. When the bullet impacts an object and makes sparks or debris - attach the sound to the sparks... This way, if the bullet ricochets, it will spark and make it's impact sound on each contact, the gun has the gun sound and the bullet the bullet sound.
     
    xr0m likes this.
  12. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    1: Please don't post in excessive bold (or caps).
    2: Tell us the actual problem.
    • What is going wrong.
    • When is it going wrong.
    • How is it going wrong.
    • Etc.
    If you have example code, please post the code in code tags. To learn more about code tags, read this:
    http://forum.unity3d.com/threads/using-code-tags-properly.143875/
     
  13. daboyzrule

    daboyzrule

    Joined:
    Sep 24, 2015
    Posts:
    3
    No, no errors in the console. I rechecked everything like the speed on the player and associating things like hazard with the asteroid. Today I reopened unity and an error that was definitely not there before appeared next to all my script components in the inspector, reading, "The associated script cannot be loaded. Please fix any errors and assign a valid script." This is odd, since when I click on the box where the script is assigned it brings me to the script and opens it in MonoDevelop. This wasn't displayed last time but the player ship still does not move.

    Sorry for my incompetence,
    Thanks
     

    Attached Files:

  14. IanSmellis

    IanSmellis

    Joined:
    Nov 2, 2014
    Posts:
    26
    Did you try removing the script and re-adding it?
     
  15. xr0m

    xr0m

    Joined:
    Sep 21, 2015
    Posts:
    4
    Check a class name of PlayerController script, I think that this happens after you have renamed the script
     
  16. CollDrag77

    CollDrag77

    Joined:
    Aug 30, 2015
    Posts:
    1
    Just after finishing the shooting shots, I press play, but my ship only moves diagonally from upper right to lower left and the shots also stick in that same line from upper right diagonally to lower left. I've have repeatedly checked my scripts against the done scripts, nothing wrong there. Please help
     
  17. daboyzrule

    daboyzrule

    Joined:
    Sep 24, 2015
    Posts:
    3

    I have already tried both of these.
    I looked through other forum threads as well and I can't find anything that would suggest a reason for the error. I don't even know if this has anything to do with my initial problem, as this error is with all scripts not just PlayerController.
     
  18. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    If there are no compile errors in the console then you must not have a valid script. You can either try to troubleshoot what's wrong with your script, or you can delete it and create a new one. Check things like the class name must match the file name of the script - exactly - including capitalisation.
     
  19. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    If you have this error on all scripts, are you SURE you don't have any compilation errors at all?
     
    IanSmellis likes this.
  20. Cylibus

    Cylibus

    Joined:
    Mar 29, 2014
    Posts:
    6
    Yes, thank you, restarting the editor fixed the issue.

    Now I'm having another issue unfortunately with the GUI Text, I've added it in as a component to an empty object as was said, but not only does no text show up, but it still moves typically along the x and z axis and not by viewport as the video says. I tried adjusting the transform and resetting to origin but still nothing comes up. Should I just continue onto scripting anyway?

     
  21. artilleryJay

    artilleryJay

    Joined:
    Sep 27, 2015
    Posts:
    5
    Hello
    I just finished your Roll-a-Ball Tutorial and want to jump into the Space Shooter straight away however; I am unable to download the asset pack. I tried doing it in the asset store and also while in Unity via the asset tab. I get ERROR over the DOWNLOAD icon, if I click the ERROR icon I get PLEASE WAIT-and after about 45 mins. still nothing. Any help would be greatly appreciated. Thank you for your help.
     
  22. artilleryJay

    artilleryJay

    Joined:
    Sep 27, 2015
    Posts:
    5
    Well, I went and took a shower, drank some coffee and the issue apparently fixed itself! Moving on with the tutorial and hopefully no new issues will arise.
     
  23. Donvermo

    Donvermo

    Joined:
    Mar 31, 2014
    Posts:
    13
    Hey Guys, I followed the entire space shooter tutorial and everything went fine until I tried converting the controls to touch.

    I used this live training as a reference to get me started but after completing it I noticed a peculiar bug.
    Whenever I am using my left thumb to fly the ship around and press the "fire button" at the same time the ship veers strongly to the right side of the screen as if the touch event is being picked up by the script in my "movement zone"

    I have been scanning the code back and forth and have tried several rounds of debugging, using the debug logger and a number of the touch events, yet have been unable to find the cause of the bug.

    I am becoming more and more convinced that it could be a setting for the canvas in my editor that is wrong but I have run out of ideas.

    Can anyone shed some light on this for me?

    SimpleTouchAreaButton

    Code (CSharp):
    1. using UnityEngine;
    2.     using UnityEngine.UI;
    3.     using UnityEngine.EventSystems;
    4.     using System.Collections;
    5.  
    6.     public class SimpleTouchAreaButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler {
    7.    
    8.         private bool touched;
    9.         private int pointerID;
    10.         private bool canFire;
    11.    
    12.         void Awake () {
    13.             touched = false;
    14.         }
    15.    
    16.         public void OnPointerDown (PointerEventData data) {
    17.             if (!touched) {
    18.                 touched = true;
    19.                 pointerID = data.pointerId;
    20.                 canFire = true;
    21.             }
    22.         }
    23.    
    24.         public void OnPointerUp (PointerEventData data) {
    25.             if (data.pointerId == pointerID) {
    26.                 canFire = false;
    27.                 touched = false;
    28.                 Debug.Log (Input.touchCount);
    29.             }
    30.         }
    31.    
    32.         public bool CanFire () {
    33.             return canFire;
    34.         }
    35.     }

    SimpleTouchPad

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3.     using UnityEngine.UI;
    4.     using UnityEngine.EventSystems;
    5.     using System.Collections;
    6.  
    7.     public class SimpleTouchPad : MonoBehaviour, IPointerDownHandler, IDragHandler, IPointerUpHandler {
    8.  
    9.         public float smoothing;
    10.  
    11.         private Vector2 origin;
    12.         private Vector2 direction;
    13.         private Vector2 smoothDirection;
    14.         private bool touched;
    15.         private int pointerID;
    16.  
    17.         void Awake () {
    18.             direction = Vector2.zero;
    19.             touched = false;
    20.         }
    21.  
    22.         public void OnPointerDown (PointerEventData data) {
    23.             if (!touched) {
    24.                 touched = true;
    25.                 pointerID = data.pointerId;
    26.                 origin = data.position;
    27.             }
    28.         }
    29.  
    30.         public void OnDrag (PointerEventData data) {
    31.             if (data.pointerId == pointerID) {
    32.                 Vector2 currentPosition = data.position;
    33.                 Vector2 directionRaw = currentPosition - origin;
    34.                 direction = directionRaw.normalized;
    35.                 Debug.Log (direction);
    36.             }
    37.         }
    38.  
    39.         public void OnPointerUp (PointerEventData data) {
    40.             if (data.pointerId == pointerID) {
    41.                 direction = Vector2.zero;
    42.                 touched = false;
    43.             }
    44.         }
    45.  
    46.         public Vector2 GetDirection () {
    47.             smoothDirection = Vector2.MoveTowards (smoothDirection, direction, smoothing);
    48.             return smoothDirection;
    49.         }
    50.     }

    PlayerController

    Code (CSharp):
    1. using UnityEngine;
    2.     using System.Collections;
    3.  
    4.     [System.Serializable]
    5.     public class Boundary {
    6.         public float xMin, xMax, zMin, zMax;
    7.     }
    8.  
    9.     public class PlayerController : MonoBehaviour {
    10.  
    11.         public Rigidbody rigidbody;
    12.         public float speed;
    13.         public float tilt;
    14.         public Boundary boundary;
    15.  
    16.         public GameObject shot;
    17.         public Transform shotSpawn;
    18.         public float fireRate;
    19.         public SimpleTouchPad touchPad;
    20.         public SimpleTouchAreaButton areaButton;
    21.  
    22.         private float nextFire;
    23.         private Quaternion calibrationQuaternion;
    24.         private AudioSource sound;
    25.  
    26.         void Start () {
    27.             sound = GetComponent<AudioSource> ();
    28.             CalibrateAccelerometer ();
    29.         }
    30.  
    31.         void Update () {
    32.             if (Time.time > nextFire) {
    33.                 if (areaButton.CanFire ()) {
    34.                 //if (areaButton.CanFire () || (Application.platform != RuntimePlatform.IPhonePlayer && Input.GetButton("Fire1"))) {
    35.                     nextFire = Time.time + fireRate;
    36.                     Instantiate(shot, shotSpawn.position, shotSpawn.rotation) ;
    37.                     sound.Play();
    38.                 }
    39.             }
    40.         }
    41.  
    42.         void FixedUpdate () {
    43.             // The Vector3 movement is overwritten once each update by a platform dependant code block
    44.             Vector3 movement;
    45.             //if (Application.platform == RuntimePlatform.IPhonePlayer) {
    46.                 Vector2 direction = touchPad.GetDirection ();
    47.                 movement = new Vector3(direction.x, 0.0f, direction.y);
    48.  
    49.                 //        Iphone input scheme using the accelerometer
    50.                 //        Vector3 accelerationRaw = Input.acceleration;
    51.                 //        Vector3 acceleration = FixAccelleration (accelerationRaw);
    52.                 //        Vector3 movement = new Vector3(acceleration.x, 0.0f, acceleration.y);
    53.  
    54.     //        } else {
    55.     //            float moveHorizontal = Input.GetAxis ("Horizontal");
    56.     //            float moveVertical = Input.GetAxis ("Vertical");
    57.     //        
    58.     //            movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    59.     //        }
    60.  
    61.             rigidbody.velocity = movement * speed;
    62.             rigidbody.position = new Vector3
    63.                 (
    64.                     Mathf.Clamp (rigidbody.position.x, boundary.xMin, boundary.xMax),
    65.                     0.0f,
    66.                     Mathf.Clamp (rigidbody.position.z, boundary.zMin, boundary.zMax)
    67.                     );
    68.          
    69.             rigidbody.rotation = Quaternion.Euler (0.0f, 0.0f, rigidbody.velocity.x * -tilt);
    70.         }
    71.  
    72.         void CalibrateAccelerometer () {
    73.             Vector3 accelerationSnapshot = Input.acceleration;
    74.             Quaternion rotateQuaternion = Quaternion.FromToRotation (new Vector3 (0.0f, 0.0f, -1.0f), accelerationSnapshot);
    75.             calibrationQuaternion = Quaternion.Inverse (rotateQuaternion);
    76.         }
    77.  
    78.         Vector3 FixAcceleration (Vector3 acceleration) {
    79.             Vector3 fixedAcceleration = calibrationQuaternion * acceleration;
    80.             return fixedAcceleration;
    81.         }
    82.  
    83.     }
    55046-canvas.png 55047-zone1.png
     
  24. chippyho123

    chippyho123

    Joined:
    Sep 27, 2015
    Posts:
    6

    Pheonix is the ship. Whay is this happening?!?!o_O
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour
    5. {
    6.     void FixedUpdate ()
    7.     {
    8.     float moveHorizontal = Input.GetAxis ("Horizontal");
    9.     float moveVertical = Input.GetAxis ("Horizontal");
    10.     rb = GetComponent<Rigidbody>()
    11.  
    12.     Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical)
    13.  
    14.             rb.velocity = movement;
    15.     }
    16. }
    Help!!!:(
     
  25. Donvermo

    Donvermo

    Joined:
    Mar 31, 2014
    Posts:
    13
    You are missing a semi colon at the end of rb = GetComponent<Rigidbody>()
     
  26. chippyho123

    chippyho123

    Joined:
    Sep 27, 2015
    Posts:
    6
    Thanx But...
    now it says: Assets/Scripts/AresControls.cs(14,26): error CS1525: Unexpected symbol `rb'
     
  27. chippyho123

    chippyho123

    Joined:
    Sep 27, 2015
    Posts:
    6
    Code:
    1. using UnityEngine;
    2. using System.Collections;

    3. public class PlayerController : MonoBehaviour
    4. {
    5. void FixedUpdate ()
    6. {
    7. float moveHorizontal = Input.GetAxis ("Horizontal");
    8. float moveVertical = Input.GetAxis ("Horizontal");
    9. rb = GetComponent<Rigidbody> ();

    10. Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical)

    11. rb.velocity = movement;
    12. }
    13. }
     
  28. Donvermo

    Donvermo

    Joined:
    Mar 31, 2014
    Posts:
    13
    It's the same issue, line 12 doesn't end in a semi colon.
    Check your code carefully, each statement should end with a semi colon.
     
  29. chippyho123

    chippyho123

    Joined:
    Sep 27, 2015
    Posts:
    6
    Now...

    Assets/Scripts/AresControls.cs(10,17): error CS0103: The name `rb' does not exist in the current context
    Assets/Scripts/AresControls.cs(13,25): error CS0103: The name `rb' does not exist in the current context

    Don't blame me. i'm new to unity
     
  30. chippyho123

    chippyho123

    Joined:
    Sep 27, 2015
    Posts:
    6
    Code:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour
    5. {
    6.     void FixedUpdate ()
    7.     {
    8.     float moveHorizontal = Input.GetAxis ("Horizontal");
    9.     float moveVertical = Input.GetAxis ("Horizontal");
    10.         rb = GetComponent<Rigidbody> ();
    11.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    12.  
    13.             rb.velocity = movement;
    14.     }
    15. }

     
  31. chippyho123

    chippyho123

    Joined:
    Sep 27, 2015
    Posts:
    6
    They say the code and assets were updated for v.5 not v.5.2.1
     
  32. Donvermo

    Donvermo

    Joined:
    Mar 31, 2014
    Posts:
    13
    It would seem you have not declared what rb is therefore the editor cannot comprehend what you are trying to reference. While it might be tempting to start off with a fancy flashy tutorial because it looks cool it might not always be the best starting point. Judging by the type of problems you are encountering I genuinely encourage you to either seek more training in C# or try an easier example first.
     
    IanSmellis likes this.
  33. artilleryJay

    artilleryJay

    Joined:
    Sep 27, 2015
    Posts:
    5
    Hello everyone,
    I am having trouble with GUIText. I am running Unity 5 and followed the steps in the annotation. I am unable to see text though. This is my GUIText layout:
    guitext.png And my game:
    upload_2015-9-27_19-11-26.png
    Did I miss something?
    If anyone is able to help I would be grateful.
     

    Attached Files:

    • play.png
      play.png
      File size:
      306.2 KB
      Views:
      821
  34. artilleryJay

    artilleryJay

    Joined:
    Sep 27, 2015
    Posts:
    5
    change the following items:
    Transform-
    position Y:1
    GUIText-
    Pixel Offset X:10 Y:-10
    Font size: try 15
     
  35. artilleryJay

    artilleryJay

    Joined:
    Sep 27, 2015
    Posts:
    5
    lmao, nvm, I'm a nooby-noober!
     
  36. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This image is from the scene view, can you see the text in the game view?

    To be absolutely sure the text is not pushed out of the camera's view port, set the transform's position to (0.5, 0.5, 0.0) and set the anchor and alignment to middle...
     
  37. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Check the FAQ on the first post of this thread, and ask: is this still an issue when deployed to the device? There seems to be a bug/issue between the UI tools and the Unity Remote.
     
  38. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Please don't use excessive CAPS or bold...
     
  39. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Please do not use excessive CAPS or Bold...
     
  40. 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/
     
  41. marcusrwatson

    marcusrwatson

    Joined:
    Sep 24, 2015
    Posts:
    10
    Hi, I had a couple of questions about the Camera and Lighting chapter.

    I'm using Unity 5.21f1, so I had to reset the skybox. The annotations say to "delete" the skybox - I'm not sure what that means, there doesn't seem to be any "delete" option. What I did was to uncheck the skybox in the scene menu, and in Windows/Lighting I just changed the associated material from whatever it was originally to "None". Is that right?

    Then with the 3 lights, I can't seem to get the overall effect to look exactly the same as in the tutorial. I believe I've set up each light and its transformations appropriately, but the ship is much darker. So instead of setting intensities to 0.75, 0.5 and 0.25, I ended up using 1.75, 1.5, and 1.25, and that seems to do the trick. This doesn't affect anything else, so I can continue through the tutorial, I'm just not sure what causes the discrepancy between my lighting and the tutorial's, so wanted to know if you had any suggestions for what I'm doing wrong.

    Thanks!
     
  42. Donvermo

    Donvermo

    Joined:
    Mar 31, 2014
    Posts:
    13
    I don't think you are doing anything wrong, Unity has changed quite a bit especially when it comes to lighting.
    This is the mostly likely cause of the discrepancy.
     
  43. Donvermo

    Donvermo

    Joined:
    Mar 31, 2014
    Posts:
    13
    Thanks, I had not tried an actual deployment yet. I must have read past that bit in the post, my bad.
     
  44. McNoguff

    McNoguff

    Joined:
    Sep 20, 2015
    Posts:
    9
    Hi! I've been playing with Unity a bit and I'm really loving the resources and community around it. I've managed to make some really fun little prototypes of ideas that have been rattling around in my head for a while. It's awesome.

    Anyway, a while back you guys had PDFs to accompany lessons; Is there anything like that for Space Shooter? I'd especially like a text tutorial on the stuff "left out" of the video, i.e. the particles and enemies. I understand most of the concepts but I'd love to understand what you guys consider best practices i.e. why you chose to do things one way and not another. That said there are obviously other tutorials out there for the particle systems and mover scripts for enemies so if it's not feasible I understand.

    Sorry if there's an obvious answer/documentation somewhere and I just haven't found it yet. Thank you for your time!
     
    Last edited: Sep 28, 2015
  45. W3lshm3n

    W3lshm3n

    Joined:
    Sep 28, 2015
    Posts:
    4
    I'm having problem with this tut. I'm on video 7 and I've figured out most of the changes between the video and Unity 5. but where I'm stuck at is shooting my bolt. the portion of code that's giving me problems is the following.

    Instantiate(shot, shotSpawn.position, shotSpawn.rotation);

    both position and rotation i'm given the this error

    Error 1 'UnityEngine.GameObject' does not contain a definition for 'position' and no extension method 'position' accepting a first argument of type 'UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?) c:\users\logan\desktop\space shooter\new unity project\assets\scripts\playercontroller.cs 29 41 Assembly-CSharp

    I've searched this post and though its been helpful with previous roadblocks I haven't had luck with fixing it.
    any guidance would be appreciated
     
  46. Cylibus

    Cylibus

    Joined:
    Mar 29, 2014
    Posts:
    6
    Ok, thank you, the anchor alignment seemed to bring it into view for me.
     
  47. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    To remove the skybox, simply delete it!

    This is a reference field like all of the other reference fields in the inspector.
    SKybox field.png

    You can either select the target button the right (the circle with the dot in the middle) and it will open up an asset picker window:
    Asset Picker Window.png

    Here you can choose "None".

    Or, you can simply select the skybox field:
    Skybox selected.png

    ... and use the backspace or delete key to remove it.

    In the end it should look like this:
    No sky box.png

    [QUOTE="marcusrwatson, post: 2315599, member: 943281"Then with the 3 lights, I can't seem to get the overall effect to look exactly the same as in the tutorial. I believe I've set up each light and its transformations appropriately, but the ship is much darker. So instead of setting intensities to 0.75, 0.5 and 0.25, I ended up using 1.75, 1.5, and 1.25, and that seems to do the trick. This doesn't affect anything else, so I can continue through the tutorial, I'm just not sure what causes the discrepancy between my lighting and the tutorial's, so wanted to know if you had any suggestions for what I'm doing wrong.

    Thanks![/QUOTE]

    One of the changes moving into Unity 5 was to remove a comedy "doubling" value to materials in the default shaders.
    http://docs.unity3d.com/Manual/UpgradeGuide5-Shaders.html

    This means "in general" lights are half as strong as they used to be in Unity 4 and earlier.

    I am producing this week a more complete updrade guide to the Space Shooter project under Unity 5, and the values I used were:
    • Key - 2.0
    • Fill - 1.0
    • Rim 0.5
    ... but you should balance these to taste. If you like your choice of lighting, then it's perfect. It doesn't affect anything later on in a technical way.
     
  48. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    First off! Yay! Fantastic! That's what I so much enjoy hearing - that you can make things you've always wanted to make. Congrats!

    Now, when it comes to PDF's per se: No, we don't usually include anything more than a primitive readme, if that. There are "articles" on our learn sections, which are written. There has been some requests/discussion about reformatting them to PDF format and make them downloadable, but there are some maintenance issues with this. Primarily that we can maintain, update and correct on-line material, but PDF's - especially once they have been released out into the wild - can become obsolete and yet still be distributed amongst the community. This we don't really want.

    When it comes to the "stretch goals" in Space Shooter (the enemy ships, multiple hazards, scrolling background) - you can find these in the "done" folder in the project downloaded from the Asset Store.

    Even more helpful, just last Monday, I did a live session covering all of these subjects (and more during Q&A). I'm in the process of editing this for the learn site, so bear with me, it should be up "soon" (tm), which I hope means by the end of the week.

    Lastly, best practices very quickly becomes a matter of intense debate.

    We present certain styles and approaches in our tutorial sessions as much based on the level of the audience as much as presenting a theoretical "best practice". If you scroll back there is a short video about using an "observer pattern" to make Space Shooter "less tightly coupled". There is a lot of merit to this way of thinking... but with Space Shooter we are trying to cover a whole large foundation of basics - from lighting to physics - and some of the strict "computer science" of the project may not be perfect when it comes to "best practices". Now, that being said, this game is so small and compact, it can handle being "tightly coupled". < Open Debate on when to teach "best practices" here... :-/ > Now, games (or programs) in the past used to be very tightly coupled as they needed to be for things like speed, efficiency and resource management (eg: memory footprint, etc.), and now with modern computers and languages, they don't need to be... Let's leave this subject with "As the projects get more advanced, they will start to be more strict on a "bet practice" level, as we teach things like Interfaces, Delegates, Inheritance, etc..
     
    McNoguff likes this.
  49. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Don't worry. From what I can see, you've fixed your problem anyway... but:

    This is a very easy problem to make!

    You probably have:
    Code (csharp):
    1. public GameObject shotSpawn;
    ... rather than:
    Code (csharp):
    1. public Transform shotSpawn;
    It's the Transform component that has position and rotation. If you use a GameObject for shotSpawn instead of Transform, you need to then write:
    Code (csharp):
    1. Instantiate(shot, shotSpawn.transform.position, shotSpawn.transform.rotation);
    This is because when the shotSpawn is a GameObject it will have a Transform component which in turn will have position and rotation.

    If you declare shotSpawn as a Transform, you are addressing the Transform component directly, so you don't need to have those extra "transform"s in your code.

    A very easy mistake to make!
     
  50. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Great! Don't forget to set it to what it needs to be (eg: Upper Left, Upper Right...) when you're ready to use it, but the two main points to take away from this is certain components (including GUIText) use the viewport to calculate its position. This puts (0, 0, z) in the lower left and (1,1, z) in the upper right (where z is pretty much ignored), and the second point is that if you are in one of the extreme corners (say upper left at (1, 1, z)) and you have your alignment set incorrectly - the text will be outside of the viewport!