Search Unity

Space Shooter Tutorial Q&A

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

  1. gizmo1990

    gizmo1990

    Joined:
    Jul 12, 2012
    Posts:
    32
    I'm now going through the 'converting to mobile' tutorial and I'm noticing that I've not got a Touch Input Module script on my EventSystem?? :( Could someone tell me where I can find this and why it's not appearing for me? Is it another version 5 issue?
     
  2. evansabove

    evansabove

    Joined:
    Feb 9, 2016
    Posts:
    9
    Hey, I had exactly the same issue. I have discovered two ways of fixing it.

    Firstly, you can move the assignment of currentspeed in the evasion script to update. This seems rather inefficient though, considering our speed remains constant so there is no need to reassign with every frame.

    A better solution is to switch the Start() function in the Mover script to the Awake() function. This means that the velocity will be applied first, which the Evasion script can then pick up.

    Otherwise the evasion script starts trying to modify the velocity before mover has a chance to give it one, meaning it gets stuck at 0.

    Hope that helps.
     
    Last edited: Feb 9, 2016
  3. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Are you using the upgrade guide? This is linked on both the lesson page and the original post for this thread:
    If this is not listed in the upgrade guide, can you please let me know, and also let me know the video name and the time that it occurs?

    I'd suspect that this is now the "Spatial Blend" property, which should be set all the way to 2D, of a value of 0:
    SpatialBlending.jpg

    http://docs.unity3d.com/Manual/class-AudioSource.html
     
    Last edited: Feb 9, 2016
  4. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Well, I'm not sure about the circumstance you are talking about. Normally, the Rigidbody.velocity is not accessible in the inspector, so if you had a prefab, you couldn't set the this, and then have it instantiated with a velocity:
    Rigidbody.png

    The usual way to set this value, is to take a reference (eg: var clone = Instantiate (myPrefab, ... etc) of the object being instantiated, and then set the value of the Rigidbody.velocity in the next line (eg: either clone.GetComponent<Rigidbody>().velocity = speed; or clone.velocity = speed; depending on how you cast the Type of clone).

    I suppose it could be possible to take a reference to a previously instantiated GameObject with a Rigidbody component attached that is already in the scene and try to use that as the object to instantiate... then I'm not sure what the value of the Rigidbody would be... That would be a very strange edge case.

    BTW - I may have lost track of the conversation. Can you remind me what it is that's giving your trouble?
     
  5. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This is indeed an upgrade issue. There is now no need for a separate touch input module. It is incorporated into the existing "input module". This step can safely be ignored.
     
  6. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Can you or @Map_Monkey remind me of the exact problem you are facing?
     
  7. xoxoroxo

    xoxoroxo

    Joined:
    Feb 9, 2016
    Posts:
    7
    Hey Adam!

    At the end of the extended tutorial you've created 3 shoots making 2 of them shooting diagonally. But when the ship was moving diagonal shoots were disappearing. I've managed to figure out that it's because the ship tilts and so the shoots hence one of them goes down and the other goes up. If that's the case is there a way to freeze the children of the ship so they don't tilt and tilt only the player? Cheers!
     
    Last edited: Feb 9, 2016
  8. evansabove

    evansabove

    Joined:
    Feb 9, 2016
    Posts:
    9
    Basically the addition of the evasive manoeuvre script caused the mover script to stop working.

    Turning off the evasive manoeuvre script fixes it.

    If I look at the debug log for the z velocity, the velocity is stuck at 0.

    I figured this was because the manoeuvre was taking the current z velocity at Start (0 if it fires before mover has a chance to) and then reassigning it every frame with update , meaning that it gets stuck at 0.

    Like I said, I fixed it by having mover assign the velocity on awake rather than at start. An alternative was to have the evasive manoeuvre script get the current velocity at update, but as we have a constant speed, this seems wasteful.
     
  9. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Heh - good point. If I remember correctly, this was an answer to a question during the live session? If so, it may not have been thoroughly though thru... but as you mention it, the tilt of the ship will tilt the spawn point, won't it?

    The solution to this in Space Shooter, when tilt is enabled, is a little complicated.

    You can't easily "un-tilt" the child, as the spawn point's position and rotation are relative to the parent.

    There are two ways that I can think of to make this work, off the top of my head.

    The first would be to architect the PlayerShip in a similar manner to the hazards and bolt, where the ship model is a child of a parent GameObject which contains only logic. This would make the model purely artwork like the hazards. Then you'd have a reference to the child model and only tilt the model - not the spawn points, which would still be child of the main parent, but not the model:
    ff5d3cd879709c3f8a9eba6cfdc600ce.png
    Note how the player ship model and spawn points are on the same hierarchical level.

    In the other solution, you'd need to do is extrapolate a point on the x-z plan at origin based on the position of the spawnPoint position and adjust its rotation so the shots are not angled out of the game plane. There may be a more clever way to do this, but this should work. This is off the top of my head, so let me know if there are any issues if you use this.
    Code (CSharp):
    1.     void Update ()
    2.     {
    3.         if (Input.GetButton("Fire1") && Time.time > nextFire)
    4.         {
    5.             nextFire = Time.time + fireRate;
    6.             Vector3 spawnPosition = new Vector3(shotSpawn.position.x, 0.0f, shotSpawn.position.z);
    7.             Quaternion spawnRotation = Quaternion.Euler(0.0f, shotSpawn.rotation.eulerAngles.y, 0.0f);
    8.             Instantiate(shot, spawnPosition, spawnRotation);
    9.             GetComponent<AudioSource>().Play ();
    10.         }
    11.     }
    I know this is missing the foreach loop, but you should be able to figure that out if you've gotten that far.
     
  10. Killiman

    Killiman

    Joined:
    Feb 12, 2016
    Posts:
    3
    Hi I was going over the Restart part of the tutorial and got stuck since LoadLevel is now obselete in Unity version 5.3.2

    Can you please let me know how to replace it? I have not been able to succesfully use LoadScene.
    I also got errors with the code for restart,text and gameOverText

    error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

    void Start()
    {
    gameOver = false;
    restart = false;
    restartText.text == "";
    gameOverText.text == "";
    score = 0;
    UpdateScore();
    StartCoroutine (SpawnWaves ());
    }

    Thanks for the support, great tutorial!
     
  11. Masterflood117

    Masterflood117

    Joined:
    Feb 12, 2016
    Posts:
    1
    Hello
    So I am halfway through the 'Moving the Player' tutorial and have written the first bit of code to get the basic movement of the ship;
    However, when I go to play, the ship does not move at all and does not respond to any input such as mouse or keyboard movement (speaking of which, I'm not sure which method of input I'm supposed to be aiming for anyway).
    Thanks

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour
    5. {
    6.     public float speed;
    7.  
    8.     void Fixedupdate ()
    9.     {
    10.         float moveHorizontal = Input.GetAxis ("Horizontal");
    11.         float moveVertical = Input.GetAxis ("Vertical");
    12.  
    13.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    14.         GetComponent<Rigidbody>().velocity = movement * speed;
    15.     }
    16. }
    17.  
     
  12. Sathyamurthy

    Sathyamurthy

    Joined:
    Feb 4, 2016
    Posts:
    4
    I have completed the game and it works. But the problem is once Player Spaceship gets destroyed, I should immediately get Restart option. Instead the instant wave of hazards are moving and then only Restart option appears. Please say how to get Restart option once Playership gets destroyed?
     
  13. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836

    Afternoon @Killiman, have a quick look at a previous post I had, might help a bit regarding using the SceneManager.
    http://forum.unity3d.com/threads/space-shooter-tutorial-q-a.313899/page-26#post-2475431

    as far as the other errors you are getting, you need to change these two lines
    Code (CSharp):
    1. restartText.text == "";
    2. gameOverText.text == "";
    to
    Code (CSharp):
    1. restartText.text = "";
    2. gameOverText.text = "";
    this is due to the double '==' being the operator for a comparison, as opposed to a single '=' being for assignment.

    should get you up and running again.
     
  14. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Afternoon @Masterflood117,

    you need to capitalise the function names correctly as they are caSe sEnsitive.

    change
    Code (CSharp):
    1. void Fixedupdate ()
    to
    Code (CSharp):
    1. void FixedUpdate ()
     
  15. takamuramamoru

    takamuramamoru

    Joined:
    Feb 14, 2016
    Posts:
    8
    Hello everyone,
    First of all let me thank the author of the series for creating such wonderful tutorials.

    I have recently started using Unity.I have just now completed this tutorial and I got a successful product in the end ,then I saved the scene by pressing command+s,then I quit Unity.The next time I opened the project,which was 5 seconds later,the game was working but the laser was hitting the astroids but the were not disappearing instead they continued to stay on screen .Also,the ship was not getting destroyed upon hitting the astroids.
    the audio file,the animation of sparks when laser hits astroids or when ship collides with the astroids were working fine.
    Thank you, your help is greatly appreciated.
     
  16. duffman82889

    duffman82889

    Joined:
    Jan 14, 2016
    Posts:
    1
    Hi Everyone!

    I just finished the explosions tutorial, and something wired happened. When I shoot the asteroid and the explosion happens (assuming when the Instantiate portion of the code is running?) the game begins to lag horribly, and I get an IsFinite(outDistanceAnalogView), IsFinite(outDistanceforSort), and Invalid AABB a errors. If I turn of explosions, the game works fine. Even if I turn off the Random Rotator, the explosions work fine without throwing any errors. But having both on, it throws the error.

    Is it something that I did wrong? I even just copied and pasted the code in just to be sure, but it's not changing anything.
     
  17. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Evening @Sathyamurthy,

    If I'm reading this correctly, what you are experiencing was by design and intentional to not give the restart option straight away after player death.

    during the spawnwaves co-routine, all the asteroids are spawned, with a small pause inbetween, then there is another pause whilst we wait for a new wave of asteroids. it was at the end of this iteration that the gameover flag is checked, and the restart flag set and a break out of the while loop, allowing the restart text to be displayed and the option to restart given to the player.

    Now, that said, if you really do want to have the option to restart given to player immediately after death you could always just put the restart text and restart flag within the public GameOver function instead of at the end of the spawnwaves co-routine to get an immediate effect. but leave the 'break' at the end of the co-routine loop so that it has an exit condition.
     
    Sathyamurthy likes this.
  18. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Evening, have a look over a previous post that may shed some light.
    http://forum.unity3d.com/threads/space-shooter-tutorial-q-a.313899/page-27#post-2483547
     
  19. bouncingboy

    bouncingboy

    Joined:
    Feb 9, 2016
    Posts:
    1
    Hi
    I'm on part 15 of the space shooter tutorial with unity 5 but my game wont end or restart, I've found that I need to use SceneManager and import it using unity engine but my game still wont stop or use any of the code. It all still works and I don't get any errors but its wont restart or end when my player dies.
    The numbers are my format lines, didn't know how to put my actual script in.

    below is my GameController script

    1 using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    using UnityEngine.SceneManagement;
    5
    public class GameController : MonoBehaviour {

    public GameObject hazard;
    public Vector3 spawnValues;
    10 public int hazardCount;
    public float spawnWait;
    public float startWait;
    public float waveWait;

    15 public Text scoreText;
    public Text restartText;
    public Text gameOverText;

    private bool gameOver;
    20 private bool restart;
    private int score;


    void Start() {
    25
    gameOver = false;
    restart = false;
    restartText.text = "";
    gameOverText.text = "";
    30 score = 0;
    UpdateScore ();
    StartCoroutine (SpawnWaves ());

    }
    35
    void Update ()
    {
    if (restart)
    {
    40 if (Input.GetKeyDown (KeyCode.R))
    {
    SceneManager.LoadScene (SceneManager.GetActiveScene().buildIndex);
    }
    }
    45 }


    IEnumerator SpawnWaves ()
    {
    50 yield return new WaitForSeconds (startWait);
    while (true)
    {
    for (int i = 0; i<hazardCount; i++)
    {
    55 Vector3 spawnPosition = new Vector3 (Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
    Quaternion spawnRotation = Quaternion.identity;
    Instantiate (hazard, spawnPosition, spawnRotation);
    yield return new WaitForSeconds (spawnWait);
    60 }
    yield return new WaitForSeconds (waveWait);

    if (gameOver)
    {
    65 restartText.text = "Press 'R' to Restart";
    restart = true;
    break;
    }
    }
    70 }
    public void AddScore (int newScoreValue)
    {
    score += newScoreValue;
    UpdateScore ();
    75 }

    void UpdateScore()
    {
    scoreText.text = "Score: " + score;
    80 }

    public void GameOver ()
    {
    gameOverText.text = "Game Over!";
    85 gameOver = true;
    }

    }


    and this is my DestroyByContact script

    1 using UnityEngine;
    using System.Collections;

    public class DestroyByContact : MonoBehaviour {
    5
    public GameObject explosion;
    public GameObject playerExplosion;
    public int scoreValue;

    10 private GameController gameController;

    void Start()
    {
    GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
    15 if (gameControllerObject != null)
    {
    gameController = gameControllerObject.GetComponent<GameController> ();
    }
    if (gameControllerObject == null)
    20 {
    Debug.Log ("cannot find 'GameController' script");
    }
    }

    25 void OnTriggerEnter (Collider other)
    {
    if (other.tag == "Boundary") {
    return;
    }
    30 Instantiate (explosion, transform.position, transform.rotation);
    if (other.tag == "Player") {
    Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
    gameController.GameOver ();
    }
    35 gameController.AddScore (scoreValue);
    Destroy (other.gameObject);
    Destroy (gameObject);
    }
    }

    any help people can give me would be really helpful

    Thanks

    EDIT
    It now works fine but I haven't touched the code since I uploaded this post
     
    Last edited: Feb 14, 2016
  20. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    First off:
    When posting code on the forums, you must use code tags.
    Please learn to use code tags properly: http://forum.unity3d.com/threads/using-code-tags-properly.143875/

    Next:
    IIRC - You'll need to update this to use the new "Scene Manager".

    This is the Scripting Reference page:
    http://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.html

    I'm running to get ready for tonight's live session, so I can't go into a lot of detail, but does this help:
    http://answers.unity3d.com/questions/1109497/unity-53-how-to-load-current-level.html
    http://stackoverflow.com/questions/34170650/unity-5-3-how-to-load-current-level

    This is related to enabling multi-scene editing:
    http://docs.unity3d.com/Manual/MultiSceneEditing.html

    Ping me if you can't get this working and I'll try to give you a hand later this week.
     
  21. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    When posting code on the forums, you must use code tags.

    Please learn to use code tags properly: http://forum.unity3d.com/threads/using-code-tags-properly.143875/
     
  22. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Please update to the newest release version of Unity. (This is at time of posting 5.3.2f1)
     
  23. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    It is possible that, if your project was "working" just fine, and then you quit and restarted and it wasn't that either you failed to save changes to your scene file, or that you made changes in playmode. If you made changes in your scene while in playmode, these changes will not persist after you leave playmode. Currently, this is by design.

    Have you been able to fix your issues?
     
  24. Sathyamurthy

    Sathyamurthy

    Joined:
    Feb 4, 2016
    Posts:
    4

    Thank you...It worked
     
  25. takamuramamoru

    takamuramamoru

    Joined:
    Feb 14, 2016
    Posts:
    8
    Thank you for replying.
    I did not change any thing while in play mode,I think I was careful about that,also since since every thing else was working fine like the animation ,sound track,I thought there was some mistake in the scripts I wrote ,but that was not the case. I am unable to get what else might be the mistake I made.
     
  26. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    So, what state are you in now?
     
  27. xoxoroxo

    xoxoroxo

    Joined:
    Feb 9, 2016
    Posts:
    7
    Hey Adam!

    I tried the first method before the second one and even it sounds easy and I understand where you're coming from I struggling how to reference to the mesh to make it tilt?
    I tried something like:

    Code (CSharp):
    1.     public GameObject ship;
    2.     public float tilt;
    3.     Mesh mesh;
    4.  
    5.     void Start () {
    6.         mesh = GetComponent<MeshFilter>().sharedMesh;
    7.     }
    8.  
    9.     void Update () {
    10.     mesh.rotation = Quaternion.Euler (0.0f, 0.0f, ship.velocity.x * -tilt);
    11.     }
    but it's of course not working.

    Should I rather go with something like:

    public Renderer rend; and take it from there?
     
    Last edited: Feb 15, 2016
  28. jmiles2015

    jmiles2015

    Joined:
    Feb 16, 2016
    Posts:
    1
    Hello everybody, I need some help seeing as this tutorial has been checked with 5.1 and not beyond.

    I'm stuck on part 14, where we add the score GUI text element. It seems that 5.3 doesn't use viewport space anymore (?) for positioning the text elements, that or I've left out a component unique to 5.3 (I've followed the upgrade notes to no effect, but again they're for 5.1 and I don't know what they changed in the past two minor versions). But that is a minor issue compared to the next that I'm having: the text isn't visible, it just remains as an empty game object with no indication that it is has a text object attached, other than the inspector showing the GUI component.

    If this can't be fixed, well there's more than one way to skin a cat and I can pull it off with a simple text object, but help understanding the GUIText problem would be beneficial.
     
  29. H_guz05

    H_guz05

    Joined:
    Feb 16, 2016
    Posts:
    3
    I came across a problem in the score video. The console says it cannot find the GameController script and it says theres a problem with the line -
    gameController.AddScore (scoreValue);
    It says "object reference not set to an instance of object"
    Also my asteroids are not being destroyed. They trigger the explosion effect but do not disappear. Neither does the player ship when it collides with the asteroids
     
  30. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Evening,

    Looking at your DestroyByContact script,

    Im assuming that the message you are getting in the console, starts with the one Adam put in the Start() method as a way to capture if it wasnt found?
    Code (CSharp):
    1. Debug.Log ("Cannot find 'GameController' script");
    The error you are getting is related to the issue whereby the gameController reference was not set, and is null.
    and you cannot use the AddScore() as gameController doesnt point to anything at present.

    If you could, check that you have assigned and spelled the tag correctly for the Game Manager in your scene, and with exactly the same capitalisation as you are searching for within your DestroyByContact script as per video, shown below.

    Code (CSharp):
    1. GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
    Just something to check.
     
    H_guz05 likes this.
  31. technano

    technano

    Joined:
    Jan 13, 2016
    Posts:
    23
    So I'm trying to change to code up a little bit so that the asteroids spawn around me as I move along but I'm getting an error and I think the error is there because I just simply don't quite know how to use the .insideUnitCircle, if that's even the right one i'm supposed to be using! If anyone knows what I could do any tips would be nice, thanks!

    Here's the code btw
    Code (CSharp):
    1. IEnumerator spawnWaves()
    2.     {
    3.         yield return new WaitForSeconds (startWait);
    4.         while (true)
    5.         {
    6.             for (int i = 0; i < hazardCount; i++) {
    7.                 Vector2 spawnPosition = new Vector2 (Random.insideUnitCircle * 5, 5);
    8.                 Quaternion spawnRotation = Quaternion.identity;
    9.                 Instantiate (hazard, spawnPosition, spawnRotation);
    10.                 yield return new WaitForSeconds (spawnWait);
    11.             }
    12.             yield return new WaitForSeconds (waveWait);
    13.  
    14.             if (gameOver)
    15.             {
    16.                 restartText.text = "Press 'R' to keep going Captain";
    17.                 restart = true;
    18.                 break;
    19.             }
    20.         }
    21.     }
     
  32. Killiman

    Killiman

    Joined:
    Feb 12, 2016
    Posts:
    3
    Hi, thanks for the help i think i got the code right, but will have to try it out later today, as for the code tags, i am not able to enter the link you posted, it says it is no longer available p :(. Will let you know if i have any other issues with this.

    Thanks again.
     
  33. Killiman

    Killiman

    Joined:
    Feb 12, 2016
    Posts:
    3
    Thanks this helped a lot!
     
  34. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Sorry. My bad for describing it that way. The mesh will be on a child GameObject. Simply gave a reference to thus GameObject's transform and affect it the same way you did in the original script.
     
  35. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Please refer to the upgrade guide for this. GUIText still uses viewport space. If you are using the retained sprite UI, you will need to position this using anchors. Please see the documentation and the learn lessons on the UI for more details. Check your GUIText anchoring and position if you are indeed using thus component, as it's possible to set the text element to render outside of the viewport if, for example, you have the text in the upper right corner and have the alignment starting from the left.
     
  36. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    What error are you getting?
     
  37. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I'm not sure what your issue was but this link works for me:
    http://forum.unity3d.com/threads/using-code-tags-properly.143875/

    Either way, please use code tags properly if you are going to post on the forum.
     
  38. technano

    technano

    Joined:
    Jan 13, 2016
    Posts:
    23
    This is the error I'm getting:
    Assets/Scripts/GameController.cs(48,99): error CS1729: The type `UnityEngine.Vector3' does not contain a constructor that takes `1' arguments

    And second of all both insideUnitCircle/Sphere spawn the asteroids in a sphere shape and I can't figure out how to keep them on the same plain as the player

    Assets/Scripts/GameController.cs(48,41): error CS0029: Cannot implicitly convert type `float' to `UnityEngine.Vector3'

    This is another error I'm getting that I'm not sure how to fix
     
    Last edited: Feb 18, 2016
  39. KAYUMIY

    KAYUMIY

    Joined:
    Nov 12, 2015
    Posts:
    115
    I have a question. I don't understand why we first dragged the texture to the quad directly when we were creating background. And Unity created automatically new material for us. After, we did not repeat this work, yet we create a new material and we drag the texture to it when we were creating quad for the bolt.
     
  40. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    A few things...

    The error:
    Assets/Example 2/Scripts/CharacterInventory.cs(12,64): error CS1729: The type `UnityEngine.Vector2' does not contain a constructor that takes `1' arguments
    ... comes from the line:
    Code (csharp):
    1. Vector2 spawnPos = new Vector2(Random.insideUnitCircle);
    In this case, you don't need to use the new keyword, you can simply assign the Vector2 variable with:
    Code (csharp):
    1. Vector2 spawnPos = Random.insideUnitCircle;
    ... as Random.insideUnitCircle returns a Vector2:

    Random.insideUnitCircle

    public static Vector2 insideUnitCircle;

    Next:
    Instantiate (http://docs.unity3d.com/ScriptReference/Object.Instantiate.html) requires either simply an Object, or an Object, Vector3 and a Quaternion.

    Object.Instantiate

    public static Object Instantiate(Object original, Vector3 position, Quaternion rotation);
    public static Object Instantiate(Object original);

    This means you can't pass in a Vector2 into "position". You need to convert this from a Vector2 into a Vector3. As Unity/C-Sharp has no clue HOW you want to convert this, you need to do it yourself. If you don't, the built in conversion will take Vector2.x and map it to Vector3.x and take Vector2.y and map it to Vector3.y and you want the Vector2 x and y to map to the Vector3 x and z, no?

    I'm unclear what's giving you the error:
    Assets/Scripts/GameController.cs(48,41): error CS0029: Cannot implicitly convert type `float' to `UnityEngine.Vector3'
    ... but this also sounds like you are trying to push a single value into a Vector3... eg:
    Code (csharp):
    1.  Vector3 myV3 = Random.Range (0.0f, 360.0f); // this doesn't work!
     
  41. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    As described in the video lesson, we are showing the audience several of the many workflows that are possible.

    It is possible to drag a texture onto a mesh model and get a standard material.

    It is possible to create a new material and customize it first, and then add it to the model.

    You choose this is the best for your workflow.
     
  42. H_guz05

    H_guz05

    Joined:
    Feb 16, 2016
    Posts:
    3
    Thank you for your help!
    I checked those lines and it looks like it is spelled correctly and the Game Controller is tagged correctly as well this is my Code maybe another set of eyes can see something I'm missing

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DestroyByContact : MonoBehaviour
    5. {
    6.     public GameObject explosion;
    7.     public GameObject playerExplosion;
    8.     public int scoreValue;
    9.     private GameController gameController;
    10.  
    11.     void Start ()
    12.     {
    13.         GameObject gameControllerObject = GameObject.FindWithTag("GameController");
    14.             if (gameController != null)
    15.             {
    16.                 gameController = gameControllerObject.GetComponent<GameController>();
    17.             }
    18.             if (gameController == null)
    19.             {
    20.                 Debug.Log ("Cannot find 'GameController' script");
    21.             }
    22.     }
    23.  
    24.     void OnTriggerEnter(Collider other)
    25.     {
    26.             if (other.tag == "Boundary")
    27.             {
    28.                 return;
    29.             }
    30.         Instantiate (explosion, transform.position, transform.rotation);
    31.             if (other.tag == "Player")
    32.             {  
    33.                 Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
    34.             }
    35.         gameController.AddScore (scoreValue);
    36.         Destroy(other.gameObject);
    37.         Destroy(gameObject);
    38.     }
    39. }
     
  43. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    arghhh, sorry I missed it myself when I read it first, It will never assign the gameController correctly as it will never get to that point of assigning it.

    At the top of your Start() function, you are creating and assigning the gameControllerObject.
    but the next line is checking to see if the gameController is null, where this should be checking the gameControllerObject.

    Snippit:
    Code (CSharp):
    1.  void Start ()
    2.     {
    3.         GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
    4.         if (gameControllerObject != null)  // change to this
    Sorry for not spotting that earlier :(
     
    H_guz05 likes this.
  44. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Good eyes!
     
    H_guz05 likes this.
  45. dmiles

    dmiles

    Joined:
    Feb 18, 2016
    Posts:
    3
    hi all,
    I'm brand-new to Unity and firstly want to say thank-you for providing these excellent tutorials! I've already successfully completed the Roll-a-Ball game and the UFO game and am just in the final stages of completing the Space Shooter tutorial. So far, I've been able to solve all of my issues by double-checking my code, re-watching the videos and checking the "Space Shooter in Unity 5" update guide (I'm running 5.3.2f1 personal). However, I found something today that I couldn't find in the update guide and I think I found a fix that works that I wanted to share. In the "Ending the game" tutorial, we are instructed to add the line:

    Application.LoadLevel (Application.loadedLevel);

    into the Update() function in GameController script to restart the game. Unfortunately, when I tried this, my script editor (I'm using MS Visual Studio) told me that these commands had been deprecated. I was able to solve it by adding

    using UnityEngine.SceneManagement;

    at the start of the GameController script, and then changing the other line to

    SceneManager.LoadScene(0);

    *note: the SceneManager function needs the SceneManagement thing included to work. Also, the 0 in the LoadScene just refers to the first and only scene in the project, so it seems to me that it's essentially doing the same thing. I'd be happy to hear if anyone else solved this in another way - feel free to comment!
     
  46. takamuramamoru

    takamuramamoru

    Joined:
    Feb 14, 2016
    Posts:
    8
    i redid the entire project, this time it is great ,had no problems
     
  47. takamuramamoru

    takamuramamoru

    Joined:
    Feb 14, 2016
    Posts:
    8
    i redid the entire project, this time it is great ,had no problems
     
  48. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yes, this has yet to be added into the update to the upgrade guide. This is something new to 5.3.
     
    dmiles likes this.
  49. dmiles

    dmiles

    Joined:
    Feb 18, 2016
    Posts:
    3
    Cool! Thanks Adam, I'm working through the "porting to mobile" tutorial for Space Shooter right now and I like your explanation style :) Also, just noticed today, when I started using the "done" assets and scene for Space Shooter that the Asteroids weren't always being 'destroyed by boundary'... it took me a little digging, but I finally realized that the Done_Asteroid prefabs have the collider in the child instead of the parent... I copied the colliders over to the parent and removed from the child and it's working perfectly now.
     
  50. trackpoth

    trackpoth

    Joined:
    Dec 25, 2015
    Posts:
    2
    Hi everyone!
    First of all, thank you for these great tutorials. I have already finished the Space Shooter ones up until the last live training, and after having done all of them I started experimenting with the aspect ratio of the game and such.

    I'd like to, to a certain extent, adapt Space Shooter to the format that games like Downwell, for example, have. But I've been having problems to replicate what I intend to do. I'll show some images to further explain my issues:




    If I understand this correctly, the other game has two cameras (one on the play view and other on the play view + UI), or is it nonsense? I'm at a loss with how these things could be dealt with.