Search Unity

Space Shooter Tutorial Q&A

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

  1. cindoll13

    cindoll13

    Joined:
    Oct 14, 2016
    Posts:
    2
    Hi,
    I'm following the official tutorial and everything goes well until I went to chapter 9--"Creating Hazards".
    The Asteroid doesn't explode even if it is collided with the bolt.However,it exploding when it's collided with my aircraft.
    I have checked and checked again with my code,but I can't find any problems.And I think "other.gameObject "refers to" player(my aircraft)"&"bolt",but why it only works on my aircraft?
    And this is my code(the same as official tutorial I think><)
    P.s.I'm so sorry for my bad English.

    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.  
    9.  
    10.     void OnTriggerEnter(Collider other)
    11.     {
    12.         if (other.tag == "Boundary")
    13.         {
    14.             return;
    15.         }
    16.         Instantiate(explosion, transform.position, transform.rotation);
    17.         if (other.tag == "Player")
    18.         {
    19.             Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
    20.         }
    21.         Destroy(other.gameObject);
    22.         Destroy(gameObject);
    23.     }
    24. }
     
  2. Omita

    Omita

    Joined:
    Dec 25, 2013
    Posts:
    11
  3. A_Savvidis

    A_Savvidis

    Joined:
    Jul 21, 2016
    Posts:
    98
    Did you remembered to drag n drop the explosion on the inspector of the script?
     
  4. cindoll13

    cindoll13

    Joined:
    Oct 14, 2016
    Posts:
    2
    I'm sure I have.Finally,I do this project again from the beginning,and it has solved.Maybe I haven't notice some steps.
    Thanks a lot.
     
  5. Haydenpete95

    Haydenpete95

    Joined:
    Oct 18, 2016
    Posts:
    3
    Hey everyone!
    My situation is driving me crazy.
    I'm trying to add score value to the asteroids but if i follow the instructions in the 3.2 video 100%, i can't destroy the asteroids at all.
    The void start () section in DestroyByContact file caused the asteroid destruction issue, so i got rid of it.
    All i need to do is find a way to implement a scoring system and add a score value to the asteroids without having this issue again.
    I need help!
    (I'm using Unity 5.4)
     
  6. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Evening,

    can you post a copy of the DestroyByContact script you had please, or try readding the Start() method as per tutorial so we can work through it to get you working again. or any errors you are getting.

    just wondering , when I was reading, as you capitalised the name of the script, but you had 'void start()' at the beginning of the post, its just that this must be capitalised correctly as per 'void Start()' or it wont get called if its got a lower case 's'.
     
  7. Polakowski

    Polakowski

    Joined:
    Oct 20, 2016
    Posts:
    1
    Hello everyone!

    I have a problem. A problem with adding power ups to the project. One of the power ups adds "double shot" to the player. But when i shot asteroid with 2 bullets at the same time i get double reward (double score etc.). In the Hierarchy i can see that i have 2 explosions from 1 asteroid. I don't know how to repair it.

    PS. Sorry for my english.
     
  8. Skyho

    Skyho

    Joined:
    Apr 3, 2015
    Posts:
    10
    I have encountered the same problem using Unity ver 5.4.1.f1. I cannot figure out how to resize to the 600 X 900 and therefore am running into issues with displaying the restart, quit and score in the appropriate locations.

    Nevermind found Scooterboy's posted solution: Create new size.JPG
     
    Last edited: Oct 23, 2016
  9. Skyho

    Skyho

    Joined:
    Apr 3, 2015
    Posts:
    10
    void Update ()
    {
    if (restart)
    {
    if (Input.GetKeyDown (KeyCode.R))
    {
    Application.LoadLevel(Application.loadedLevel);
    }
    }.Load
    }

    Visual Studio is pulling red error codes when I change this to SceneManager.LoadScene (SceneManager.LoadedScene);

    Anyone know if SceneManager works yet?
     
  10. zykx28

    zykx28

    Joined:
    Oct 23, 2016
    Posts:
    1
    I have been having some trouble with the boundary on step 5 of the Space Shooter. the error is as follow:

    NullReferenceException: Object reference not set to an instance of an object
    PlayerController.FixedUpdate () (at Assets/Scripts/PlayerController.cs:30)


    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. [System.Serializable]
    5. public class Boundary
    6. {
    7.     public float xMin, xMax, zMin, zMax;
    8. }
    9.  
    10. public class PlayerController : MonoBehaviour
    11. {
    12.     private Rigidbody rb;
    13.  
    14.     public float speed;
    15.     public Boundary boundary;
    16.     public float tilt;
    17.  
    18.  
    19.     void Start()
    20.     {
    21.         Rigidbody rb = GetComponent<Rigidbody>();
    22.     }
    23.  
    24.     void FixedUpdate()
    25.     {
    26.         float moveHorizontal = Input.GetAxis("Horizontal");
    27.         float moveVertical = Input.GetAxis("Vertical");
    28.  
    29.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    30.         rb.velocity = (movement * speed);
    31.  
    32.         rb.position = new Vector3
    33.             (
    34.             Mathf.Clamp(rb.position.x, boundary.xMin, boundary.xMax),
    35.             0.0f,
    36.             Mathf.Clamp(rb.position.z, boundary.zMin, boundary.zMax)
    37.             );
    38.         rb.rotation = Quaternion.Euler(0.0f, 0.0f, rb.velocity.x * -tilt);
    39.     }
    40.    
    41. }
    42.  
     
  11. z3

    z3

    Joined:
    Jun 3, 2016
    Posts:
    34
    i think and i have no idea about c# but i did complete the tutorial take the word Rigidbody out of the start section so its just
    rb=GetComponent<Rigidbody>(); //that should fix it
     
  12. WingedOne

    WingedOne

    Joined:
    Jul 27, 2016
    Posts:
    7
    I finished up with the tutorial about adapting the Space Shooter to mobile and everything was working fine. I exported everything to a Unity package because I wanted to make some changes with a new project. However, when I re-imported the package to a new project and re-built it for mobile it was like all the colliders stopped working. Everything was going through everything else like they weren't there.

    I went back and forth a couple of times to check. The mobile project I finished worked fine but when I exported it as a Unity package and re-imported it to another project I got the same behavior of collisions not seeming to work.

    Any ideas what I might be doing wrong with exporting/importing?
     
  13. avnkailash

    avnkailash

    Joined:
    Oct 26, 2016
    Posts:
    1
    Iam following the tutorial to build the space shooter for Mobile. I have completed adding the touch controls. The player ship is moving as expected but the issue is : I am not able to view the text UI elements in my game. I have followed the instructions from the video tutorial but not able to view them while playing.

    The catch is : I am able to see them when I play directly from the Unity editor and use the Unity Remote to control my player object. But when I generate the apk file and install in my android phone, I am unable to view the score and game over text elements. I am able to view Restart button. FYI, the Score and GAME OVER messages are displayd using Texst UI element and Restart is displayed as a button(this is visible but not the text UI elements)
     
  14. Emoangel_1478

    Emoangel_1478

    Joined:
    May 20, 2016
    Posts:
    4
    my spaceship won't move I am not sure what I am doing wrong. The convex is checked and the code is written like it tells me to.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour
    5. {
    6.     private Rigidbody rig;
    7.     void Start ()
    8.     {
    9.         rig = GetComponent<Rigidbody>();
    10.     }
    11.     public float speed;
    12.     void Fixedupdate ()
    13.     {
    14.         float moveHorizontal = Input.GetAxis ("Horizontal");
    15.         float moveVertical = Input.GetAxis ("Vertical");
    16.  
    17.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    18.         rig.velocity = movement * speed;
    19.     }
    20. }
    21.  
    I have tried this code so many different ways.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour
    5. {
    6.     private Rigidbody rd;
    7.  
    8.     public float speed;
    9.  
    10.     void Start ()
    11.     {
    12.         rd = GetComponent<Rigidbody> ();
    13.     }
    14.  
    15.     void Fixedupdate ()
    16.     {
    17.         float moveHorizontal = Input.GetAxis ("Horizontal");
    18.         float moveVertical = Input.GetAxis ("Vertical");
    19.  
    20.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    21.         rd.velocity = (movement * speed);
    22.     }
    23. }
    24.  
     
    Last edited: Oct 26, 2016
  15. Emoangel_1478

    Emoangel_1478

    Joined:
    May 20, 2016
    Posts:
    4

    I used your code to fix my problem. I couldn't get my ship to move either but once I copied your code it worked. your problem could be that you didn't check the convex under the mesh collider. Try that hope it helps.
     
  16. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Just thinking off the top of my head, as im not at PC. Might be worth checking if the text box is too small, possibly on a smaller resolution the text may be truncated and not showing. could try enlarging the text box or check to see where the anchors are set correctly, also could try testing by changing the vertical overflow from truncate to overflow.

    Some more info here on UI Text that might help
    https://unity3d.com/learn/tutorials/topics/user-interface-ui/ui-text
     
  17. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    when the package was imported, was there any errors when you tried playing it? did all the colliders come across with say the player, and the asteroids prefabs?
     
  18. nwzebra

    nwzebra

    Joined:
    Dec 4, 2015
    Posts:
    16
    Whenever I get into this situation, I drop breadcrumbs, that is Debug.Log statements to see if methods are called and the value of variables. Try and add Debug.Log("FixedUpdate: moveHorizontal " + moveHorizontal); to FixedUpdate. If you see nothing in the Console window, then either the script is not attached or the GameObject it is attached to is not enabled.
     
    OboShape likes this.
  19. nwzebra

    nwzebra

    Joined:
    Dec 4, 2015
    Posts:
    16
    The actual statement should be:
    Code (csharp):
    1.  SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     
  20. WingedOne

    WingedOne

    Joined:
    Jul 27, 2016
    Posts:
    7
    Hi. I checked for errors and it gave me an error about "Tag 'Enemy' undefined". I found that after importing the package and then running the project in Unity, it would erase all my custom tags from the project for some reason. I found that re-selecting the tags on everything and saving my scene after importing it solved my problem.
     
    Last edited: Oct 27, 2016
    OboShape likes this.
  21. Ultimate360

    Ultimate360

    Joined:
    Oct 28, 2016
    Posts:
    27
    Hi, I have a question on Game Controller - 11 - Space Shooter at 4:40 timeline in the video;
    Why can't we just use spawnPosition variable in GameController.cs?

    This seem work fine, same result... please enlighten me.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class GameController : MonoBehaviour
    5. {
    6.     public GameObject hazard;
    7.     public Vector3 spawnPosition;
    8.  
    9.     void Start()
    10.     {
    11.         spawnWaves();
    12.     }
    13.  
    14.     void spawnWaves()
    15.     {
    16.         spawnPosition = new Vector3(Random.Range(-spawnPosition.x, spawnPosition.x), spawnPosition.y, spawnPosition.z);
    17.         Quaternion spawnRotation = Quaternion.identity;
    18.         Instantiate(hazard, spawnPosition, spawnRotation);
    19.     }
    20. }
    What's in the tutorial is this: (is this something to do with clean coding or good practices? or even with optimization or something?)
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class GameController : MonoBehaviour
    5. {
    6.     public GameObject hazard;
    7.     public Vector3 spawnValues;
    8.  
    9.     void Start()
    10.     {
    11.         spawnWaves();
    12.     }
    13.  
    14.     void spawnWaves()
    15.     {
    16.         Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
    17.         Quaternion spawnRotation = Quaternion.identity;
    18.         Instantiate(hazard, spawnPosition, spawnRotation);
    19.     }
    20. }
    [Edit]
    Oh nevermind, I understand now...
    In Game Controller - 11 - Space Shooter at 4:40 timeline, the person in tutorial asked why we can't just used spawn position here? His explanation at 5:40-6:15 timeline, I still don't get it why. Not until; in Spawning Waves - 12 - Space Shooter, I have see the problem, if you just used the spawnPosition variable, it will keep overwrite the spawnPosition.x per progress, which is not good.

    It is just like this:
    Vector3 spawnPosition = new Vector3(Random.Range(-spawnPosition.x, spawnPosition.x), spawnPosition.y, spawnPosition.z);
    If you set Vector3 spawnPosition
    X:6 | Y:0 | Z:16
    You'll get a random number for X between -6 (inclusive) to 6 (inclusive):
    Initially: Vector3 spawnPosition = new Vector3(Random.Range(-6, 6), 0, 16);
    If you get like 4 or -4, you'll have:
    Then: Vector3 spawnPosition = new Vector3(Random.Range(-4, 4), 0, 16);
    Until the random range become smaller and smaller:
    Next: Vector3 spawnPosition = new Vector3(Random.Range(-1.24, 1.24), 0, 16);
    Next: Vector3 spawnPosition = new Vector3(Random.Range(-0.002631, 0.002631), 0, 16);
    Next: Vector3 spawnPosition = new Vector3(Random.Range(-1.3041e20, 1.3041e20), 0, 16);
    Next: Vector3 spawnPosition = new Vector3(Random.Range(-1.2167e40, 1.2167e40), 0, 16);
    As a result, the respawn will look like all of your asteroid respawn lining up at the middle top of the scene.

    Wrong:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class GameController : MonoBehaviour
    5. {
    6.     public GameObject hazard;
    7.     public Vector3 spawnPosition;
    8.     public int spawnCount;
    9.     public float spawnWait;
    10.  
    11.     void Start()
    12.     {
    13.         StartCoroutine(spawnWaves());
    14.     }
    15.  
    16.     IEnumerator spawnWaves()
    17.     {
    18.         for (int i = 0; i < spawnCount; i++)
    19.         {
    20.             spawnPosition = new Vector3(Random.Range(-spawnPosition.x, spawnPosition.x), spawnPosition.y, spawnPosition.z);
    21.             Quaternion spawnRotation = Quaternion.identity;
    22.             Instantiate(hazard, spawnPosition, spawnRotation);
    23.             yield return new WaitForSeconds(spawnWait);
    24.         }
    25.     }
    26. }
    That's why we need to used other variable to hold it:
    Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);

    The right code:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class GameController : MonoBehaviour
    5. {
    6.     public GameObject hazard;
    7.     public Vector3 spawnValues;
    8.     public int spawnCount;
    9.     public float spawnWait;
    10.  
    11.     void Start()
    12.     {
    13.         StartCoroutine(spawnWaves());
    14.     }
    15.  
    16.     IEnumerator spawnWaves()
    17.     {
    18.         for (int i = 0; i < spawnCount; i++)
    19.         {
    20.             Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
    21.             Quaternion spawnRotation = Quaternion.identity;
    22.             Instantiate(hazard, spawnPosition, spawnRotation);
    23.             yield return new WaitForSeconds(spawnWait);
    24.         }
    25.     }
    26. }
     
    Last edited: Nov 1, 2016
  22. Pocketknife316

    Pocketknife316

    Joined:
    Sep 21, 2016
    Posts:
    6
    Hi Adam, I'm on the "GameController" session. It won't let me drop the asteroid prefab into the hazard slot. There is also an error:

    ArgumentException: The thing you want to instantiate is null.
    UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:102)
    UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:79)
    GameController.SpawnWaves () (at Assets/_Scripts/GameController.cs:18)
    GameController.Start () (at Assets/_Scripts/GameController.cs:11)


    here is my script:


    using UnityEngine;
    using System.Collections;

    public class GameController : MonoBehaviour
    {
    public GameController hazard;
    public Vector3 spawnValues;

    void Start()
    {
    SpawnWaves();
    }

    void SpawnWaves ()
    {
    Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
    Quaternion spawnRotation = Quaternion.identity;
    Instantiate(hazard, spawnPosition, spawnRotation);
    }
    }
     
  23. Root13

    Root13

    Joined:
    Nov 2, 2016
    Posts:
    12
    Great, that all the problems are solved before:)
     
  24. z3

    z3

    Joined:
    Jun 3, 2016
    Posts:
    34
    Pocketknife316
    public GameController hazard;
    should be
    public GameObject hazard;
    I think.
     
  25. drfever

    drfever

    Joined:
    Oct 31, 2016
    Posts:
    1
    Remove the ; at the end line 21
     
  26. scruff311

    scruff311

    Joined:
    Nov 3, 2016
    Posts:
    1
    I've ported the Space Shooter game to mobile by following the last tutorial video in the series. The aspect ratio used for the screen in the video was iPhone 4 Tall (640x960). I'd like to play this on an iPhone 6 so I chose iPhone 5 Tall (9:16). Everything looks fine when I select this aspect ratio, however during gameplay the player object can now go off screen completely on the x axis (left and right). What would need to change to allow the game to work correctly in 9:16 aspect ratio?
     
  27. RedEarth

    RedEarth

    Joined:
    Nov 4, 2016
    Posts:
    23
    Hi Adam and everyone!

    So I'm not sure what happened but I was just at the end of the Spawning Waves lesson (setting up waveWait) and ran the final test when I discovered my bolts no longer collide with the asteroids. They just pass through them. Everything was working in the preceding test but suddenly it stopped. I'm completely stumped. To the best of my ability, I've double checked the code and it seems to be accurate. I cant understand why it would suddenly stop working while I'm working on unrelated code.

    Has anyone experienced this before? Does anyone here know of any potential causes or can point me in the right direction? Thanks.


    Edit: I figured the problem was in the DestroyByContact script. I tried copying the code from the lesson and it worked. Visual Studio had prompted something I didn't understand and I believe it altered the script somehow (formatting maybe?). In any case it's working again.
     
    Last edited: Nov 4, 2016
  28. mitchell_proost

    mitchell_proost

    Joined:
    Nov 8, 2016
    Posts:
    4
    I am having an issue with the DestroyByContactCode. I am in the middle of creating the GUI text score and my console is telling me that The type or namespace name `GameController' could not be found. Are you missing a using directive or an assembly reference? I have been stuck on this for a day now and can't seem to figure out a fix. Please Help!!!! :)

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class AsteroidByContact : MonoBehaviour
    5. {
    6.     public GameObject explosion;
    7.     public GameObject playerExplosion;
    8.     public int scoreValue;
    9.     public GameController gameController;
    10.  
    11.     void Start ()
    12.     {
    13.         GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
    14.         if (gameControllerObject != null)
    15.         {
    16.             gameController = gameControllerObject.GetComponent <GameContoller>();
    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.             return;
    28.         }
    29.         Instantiate (explosion, transform.position, transform.rotation);
    30.         if (other.tag == "Player") {
    31.             Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
    32.         }
    33.         gameController.AddScore (scoreValue);
    34.         Destroy (other.gameObject);
    35.         Destroy (gameObject);
    36.     }
    37. }
    38.  
     
  29. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    couple of things to double check.

    Ensure that you have assigned the tag "GameController" to your GameController object. as when you create the tag it doesnt assign it at that point, you have to set it after you create it.

    also

    on your line 16, where you have
    Code (CSharp):
    1. gameController = gameControllerObject.GetComponent <GameContoller>();
    looks like you misspelt the component name at the end, try the following
    Code (CSharp):
    1. gameController = gameControllerObject.GetComponent <GameController>();
     
  30. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    have you altered the boundary values as this will determine where the X and Z limits for movement.
     
  31. NickCoss40

    NickCoss40

    Joined:
    Nov 6, 2016
    Posts:
    2
    I had a problem with my fire button working. I copy and pasted and made sure all code was correct.
    It turns out that the problem was that my Update procedure was not working. I pasted my Input.Getbutton and Instansiate (shot) code in the void Fixed update procedure and .... It Worked!!
    Why is this? Here is the code I have . I commented out much of it to debug.

    [

    using UnityEngine;
    using System.Collections;
    [System.Serializable]
    publicclassBoundry
    {
    publicfloat xMin, xMax, zMin, zMax;
    }
    publicclassPlayerController : MonoBehaviour
    {
    publicfloat speed;
    publicfloat tilt;
    publicBoundry boundry;
    publicGameObject shot;
    publicTransform shotSpawn;
    publicfloat fireRate;
    privatefloat nextFire;
    //private float myTime = 0.0F;
    void update()
    {
    //myTime = myTime + Time.deltaTime;
    //if (Input.GetButton("Fire1")) //&& Time.time > nextFire)
    //{
    //nextFire = Time.time + fireRate;
    // Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
    // create code here that animates the newProjectile
    //nextFire = nextFire - myTime;
    //myTime = 0.0F;
    //}
    }



    void FixedUpdate ()
    {
    if (Input.GetButton("Fire1"))
    Instantiate(shot, shotSpawn.position, shotSpawn.rotation);

    float moveHorizontal = Input.GetAxis ("Horizontal");
    float moveVertical = Input.GetAxis ("Vertical");
    Vector3 movement = newVector3 (moveHorizontal, 0.0f, moveVertical);
    GetComponent<Rigidbody>().velocity = movement * speed;
    GetComponent<Rigidbody>().position = newVector3
    (
    Mathf.Clamp (GetComponent<Rigidbody>().position.x, boundry.xMin, boundry.xMax ),
    0.0f,
    Mathf.Clamp (GetComponent<Rigidbody>().position.z, boundry.zMin, boundry.zMax )
    );
    GetComponent<Rigidbody> ().rotation = Quaternion.Euler (0.0f, 0.0f,GetComponent<Rigidbody>().velocity.x * -tilt );
    }
    }
     

    Attached Files:

  32. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    the primary issue that I can see is that this line is incorrect
    Code (CSharp):
    1. void update()
    it should be Update with a capital 'U'
    Code (CSharp):
    1. void Update()
    this is something that you should look out for as C# is case sensitive. in that Update and update are two different things altogether. Just look out for these monobehaviours being capitalised correctly like Start() FixedUpdate Update() etc., if they are not capitalised or spelled correctly they wont work, they wont throw any errors, they just simply wont get called.
     
    NickCoss40 likes this.
  33. NickCoss40

    NickCoss40

    Joined:
    Nov 6, 2016
    Posts:
    2
    that was it, an overlooked lowercase 'Update.'
    Thanks buddy, I was pulling my hair for minute there.
     
    OboShape likes this.
  34. childeror

    childeror

    Joined:
    Nov 11, 2016
    Posts:
    3
    hi im new with unity and follow this tutorial, in the first i have a problem with script application.load and it solved with SceneManager but after that there is some problem after press the "R" code my scene was change like this picture
     

    Attached Files:

    • tes1.jpg
      tes1.jpg
      File size:
      102.8 KB
      Views:
      784
  35. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    I cant remember why it does it, but I remember having something similar a while back. Sorry dont have a more complete answer for you.
    could try opening the lighting window and uncheck using auto baking the scenes lights.

    Window > Lighting > Other Settings. Turn off Auto and press Build.

    see if that helps.
     
  36. childeror

    childeror

    Joined:
    Nov 11, 2016
    Posts:
    3
    thank you sir it work's
     
  37. nonfiction

    nonfiction

    Joined:
    Nov 12, 2016
    Posts:
    1
    In the Edit list. there is no Render Settings, so I cannot alter ambient light setting. Does my unity program has a problem?
     
  38. RaihaUy

    RaihaUy

    Joined:
    Nov 12, 2016
    Posts:
    2
    Hi i'm new here in Unity, I tried to follow the script for moving the space shooter (see attached screenshot). it works but my space shooter keeps multiplying whenever I move. :( can somebody tell me wrong with it? Thanks much! :)
     

    Attached Files:

    • a.jpg
      a.jpg
      File size:
      389.8 KB
      Views:
      688
  39. peterjp80

    peterjp80

    Joined:
    Nov 14, 2016
    Posts:
    1
    I was having an issue where the enemy wouldn't move. After some debugging I realized it was because I had my EvasiveManeuver script above my Mover script. If I edit the EvasiveManeuver script and move currentSpeed = rb.velocity.z; to the FixedUpdate() method instead of keeping it in the Start() method, it works as expected regardless of which position I place the scripts in. Is there a good reason to keep it in the Start() method (performance, convention, etc)?
     
  40. JHTorkveen

    JHTorkveen

    Joined:
    Nov 2, 2016
    Posts:
    3
    How would you go about adding a "grading" of each wave? Say if you hit under five objects, text pops up on the screen saying "Mediocre", and then scaling up until 10/10 where "PERFECT" would pop up?

    Great tutorial, though! Really beginner friendly and well-explained.
     
  41. childeror

    childeror

    Joined:
    Nov 11, 2016
    Posts:
    3
    hi i'm trying in tutorial Converting Space Shooter to Mobile but after complete the tutor and build it(i build for android device) the player and asteroid can't load in mobile device, any have the same problem and problem solve with this?

    this picture from my mobile device
     

    Attached Files:

    Last edited: Nov 16, 2016
  42. dgibso29

    dgibso29

    Joined:
    Oct 1, 2016
    Posts:
    6
    I've gotten to the point of building the game, and I seem to be stuck on an error with il2cpp.exe -- converting to C++, as I understand it. I've spent the last hour or so searching, both this thread and via google, with no workaround. I've upgraded to the latest beta (5.5.0b11) to no avail. I have set API compatability to .NET 2.0 as well -- no dice.

    Edit: To be clear, I'm attempting to build in WebGL. A PC build works without issue.

    I'm at a loss.
    Code (CSharp):
    1. Failed running D:\Program Files\Unity\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --enable-symbol-loading --development-mode --compile-cpp --libil2cpp-static --platform="WebGL" --architecture="EmscriptenJavaScript" --configuration="Release" --outputpath="D:\Dropbox\Dropbox\Earring Pranks Studios, LLC\Daniel\Coding\Practice Projects\Space Shooter Tut\Assets /../Temp/StagingArea/Data\Native\build.js" --cachedirectory="D:\Dropbox\Dropbox\Earring Pranks Studios, LLC\Daniel\Coding\Practice Projects\Space Shooter Tut\Assets\..\Library/il2cpp_cache" --compiler-flags="-Oz -DIL2CPP_EXCEPTION_DISABLED=1 " --linker-flags="-s PRECISE_F32=2 -s DISABLE_EXCEPTION_CATCHING=0 --memory-init-file 1 -O3 -s NO_EXIT_RUNTIME=1 -g2 -s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1 -s USE_WEBGL2=1 -s TOTAL_MEMORY=268435456 --separate-asm --emit-symbol-map --output_eol linux -s MEMFS_APPEND_TO_TYPED_ARRAYS=1 " --js-pre="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\prejs\FileSystem.js" --js-pre="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\prejs\MediaDevices.js" --js-pre="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\prejs\SendMessage.js" --js-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\Audio.js" --js-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\Cursor.js" --js-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\Eval.js" --js-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\FileSystem.js" --js-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\Logging.js" --js-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\SystemInfo.js" --js-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\UnetWebSocket.js" --js-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\WebCam.js" --js-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\WebRequest.js" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_AIModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_AnimationModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_AudioModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_ClothModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_CloudWebServicesModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_CoreModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_CrashReportingModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_IMGUIModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_JSONSerializeModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_ParticlesLegacyModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_ParticleSystemModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_Physics2DModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_PhysicsModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_TerrainModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_TerrainPhysicsModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_TextRenderingModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_UIModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_UmbraModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_UNETModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_UnityAdsModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_UnityAnalyticsModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_UnityConnectModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_UnityWebRequestModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_VehiclesModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_VideoModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_VRModule_Dynamic.bc" --additional-libraries="D:\Program Files\Unity\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules_development\WebGLSupport_WebModule_Dynamic.bc" --extra-types.file="D:\Program Files\Unity\Editor\Data\il2cpp\il2cpp_default_extra_types.txt" --assembly="D:\Dropbox\Dropbox\Earring Pranks Studios, LLC\Daniel\Coding\Practice Projects\Space Shooter Tut\Temp\StagingArea\Data\Managed\Assembly-CSharp.dll" --assembly="D:\Dropbox\Dropbox\Earring Pranks Studios, LLC\Daniel\Coding\Practice Projects\Space Shooter Tut\Temp\StagingArea\Data\Managed\UnityEngine.Analytics.dll" --assembly="D:\Dropbox\Dropbox\Earring Pranks Studios, LLC\Daniel\Coding\Practice Projects\Space Shooter Tut\Temp\StagingArea\Data\Managed\UnityEngine.dll" --generatedcppdir="D:\Dropbox\Dropbox\Earring Pranks Studios, LLC\Daniel\Coding\Practice Projects\Space Shooter Tut\Temp\StagingArea\Data\il2cppOutput"
    2.  
    3. stdout:
    4. IL2CPP error (no further information about what managed code was being converted is available)
    5. Additional information: Build a development build for more information. Failed to resolve assembly: 'D:\Dropbox\Dropbox\Earring Pranks Studios, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
    6. il2cpp.exe didn't catch exception: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'D:\Dropbox\Dropbox\Earring Pranks Studios, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
    7.   at Unity.IL2CPP.Common.AssemblyLoader.Resolve(IMetadataScope scope)
    8.   at Unity.IL2CPP.Common.AssemblyLoader.Load(String name)
    9.   at Unity.IL2CPP.AssemblyConverter.<CollectAssembliesToConvert>m__1(NPath path)
    10.   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
    11.   at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
    12.   at System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection, IEqualityComparer`1 comparer)
    13.   at Unity.IL2CPP.AssemblyConverter.CollectAssembliesRecursive(IEnumerable`1 assemblies)
    14.   at Unity.IL2CPP.AssemblyConverter.CollectAssembliesToConvert()
    15.   at Unity.IL2CPP.AssemblyConverter.PreProcessStage(InflatedCollectionCollector& genericsCollectionCollector, TypeDefinition[]& allTypeDefinitions)
    16.   at Unity.IL2CPP.AssemblyConverter.Apply()
    17.   at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies(NPath[] assemblies, NPath outputDir, NPath dataFolder)
    18.   at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies(IEnumerable`1 assemblyDirectories, IEnumerable`1 explicitAssemblies, NPath outputDir, NPath dataFolder)
    19.   at il2cpp.Program.DoRun(String[] args)
    20.   at il2cpp.Program.Run(String[] args)
    21.   at il2cpp.Program.Main(String[] args)
    22. stderr:
    23.  
    24. Unhandled Exception: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'D:\Dropbox\Dropbox\Earring Pranks Studios, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
    25.   at Unity.IL2CPP.Common.AssemblyLoader.Resolve(IMetadataScope scope)
    26.   at Unity.IL2CPP.Common.AssemblyLoader.Load(String name)
    27.   at Unity.IL2CPP.AssemblyConverter.<CollectAssembliesToConvert>m__1(NPath path)
    28.   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
    29.   at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
    30.   at System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection, IEqualityComparer`1 comparer)
    31.   at Unity.IL2CPP.AssemblyConverter.CollectAssembliesRecursive(IEnumerable`1 assemblies)
    32.   at Unity.IL2CPP.AssemblyConverter.CollectAssembliesToConvert()
    33.   at Unity.IL2CPP.AssemblyConverter.PreProcessStage(InflatedCollectionCollector& genericsCollectionCollector, TypeDefinition[]& allTypeDefinitions)
    34.   at Unity.IL2CPP.AssemblyConverter.Apply()
    35.   at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies(NPath[] assemblies, NPath outputDir, NPath dataFolder)
    36.   at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies(IEnumerable`1 assemblyDirectories, IEnumerable`1 explicitAssemblies, NPath outputDir, NPath dataFolder)
    37.   at il2cpp.Program.DoRun(String[] args)
    38.   at il2cpp.Program.Run(String[] args)
    39.   at il2cpp.Program.Main(String[] args)
    40.  
    41. UnityEngine.Debug:LogError(Object)
    42. UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:96)
    43. UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(ICollection`1, String, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:250)
    44. UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:113)
    45. UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry, Boolean) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:39)
    46. UnityEditor.HostView:OnGUI()
    47.  

    All insight is appreciated! Thanks!
     
    Last edited: Nov 16, 2016
  43. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    It looks like something in your project is trying to reference an assembly at "D:\Dropbox\Dropbox\Earring Pranks Studios.dll" Should that file be used by something in the project? If so does that file exist at that location?
     
  44. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Hi,

    the ambient light settings can now be found in the lighting tab.

    if you go to Window > Lighting.

    should see the the ambient color and source there
     
  45. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    As far as I'm aware the component/script execution order in the inspector is arbitrary ( but would be interesting to find out if it is or not for definite). In that all Start() methods are called simultaneously before any Update() methods are called.

    so the Start() method on the Mover script sets the speed of the rigidbody, and the Start() method on the EvasiveManouver relies on that being set first.

    One way around that would be to change the Mover script to use Awake() instead of start, that way Awake() is called before Start() methods are called.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Mover : MonoBehaviour
    5. {
    6.     public float speed;
    7.  
    8.     void Awake ()
    9.     {
    10.         GetComponent<Rigidbody>().velocity = transform.forward * speed;
    11.     }
    12. }
     
  46. dgibso29

    dgibso29

    Joined:
    Oct 1, 2016
    Posts:
    6
    None of that is referenced, nor does it or should it exist. Gah.
     
  47. faheem889

    faheem889

    Joined:
    Nov 19, 2016
    Posts:
    2
    Hi respectable comrades,
    I want to extend space shooter with Levels, pause and play features, load and save features can anybody help me?
     
  48. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Have a look around the Learn site at the tutorials and live training archived sessions.
    Theres a few of them that cover some of that mechanics, should be able to bring some of those ideas and concepts together.
     
  49. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    This is most likely because the tags are stored in your ProjectSettings file. I don't believe importing a package will overwrite the existing project's file, so it will keep your current tag settings.
     
  50. feihp

    feihp

    Joined:
    Nov 23, 2016
    Posts:
    4
    I follow the video steps, but the laser does not shoot, what is the problem?

    using UnityEngine;
    using System.Collections;

    public class Mover : MonoBehaviour
    {
    private Rigidbody rb;
    public float speed;

    void start ()
    {
    rb = GetComponent<Rigidbody>();
    rb.velocity = transform.forward * speed;
    }

    }