Search Unity

Space Shooter Tutorial Q&A

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

  1. yakkmeister

    yakkmeister

    Joined:
    Oct 14, 2017
    Posts:
    2
    [/QUOTE]

    While I found a way around the problem, I was certain it would be something small ...

    I went back to test your fix and it's 100% effective. Thankyou very much!
     
  2. VisceralSkies

    VisceralSkies

    Joined:
    Oct 14, 2017
    Posts:
    1
    I got stuck on this too! I found the solution in the comments section of YouTube of all places. The trick was up at the top of your "GameController" script, you have to include the code below, without the parenthesis:

    "using UnityEngine.SceneManagement;"

    And here's how my void Update function code looks:
    Code (csharp):
    1.  
    2.  void Update()
    3.     {
    4.         if (restart)
    5.         {
    6.             if (Input.GetKeyDown (KeyCode.R))
    7.             {
    8.                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    9.             }
    10.         }
    11.     }
    12.  
    Hope that helps!
     
    tpanavas likes this.
  3. Leede

    Leede

    Joined:
    Oct 4, 2017
    Posts:
    4
    Need help, my bolts are oriented correctly but they travel downwards.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Mover : MonoBehaviour
    6. {
    7.     private Rigidbody rb;
    8.     public float speed;
    9.     void Start ()
    10.     {
    11.         rb = GetComponent<Rigidbody> ();
    12.         rb.velocity = transform.forward * speed;
    13.     }
    14. }
    15.  
    No clue what's wrong, but I don't think it's the code.
     
  4. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    perhaps:

    upload_2017-10-16_15-37-30.png

    upload_2017-10-16_15-38-4.png

    upload_2017-10-16_15-39-28.png
     
  5. electr0kewt

    electr0kewt

    Joined:
    Oct 11, 2017
    Posts:
    4
     
  6. electr0kewt

    electr0kewt

    Joined:
    Oct 11, 2017
    Posts:
    4

    Hey Gwnguy! Thank you so much for your response!

    Here is my prefab in the inspector & my code on the mover script. They all seem the same as yours.

    Im considering redoing that chapter in the tutorial but im pretty sure I didn't miss anything.

    Any other suggestions would be amazing :) Do you spot a difference in your inspector/script?

    Kind regards,
    Shaun
     

    Attached Files:

  7. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    My asteroid and and its child are slightly different - I have the Rigidbody attached to the parent game object.
    Are you having the same issue as Leede, ie the travel direction of the gameobject (asteroid in your case, shot in his case)?
    Here are my asteroid GOs:
    upload_2017-10-17_9-46-57.png
    upload_2017-10-17_9-47-58.png upload_2017-10-17_9-46-57.png upload_2017-10-17_9-47-58.png
     
    electr0kewt likes this.
  8. pablothetacoman1812

    pablothetacoman1812

    Joined:
    Sep 25, 2017
    Posts:
    5
    I'm new to Unity and I've been going through the space shooter tutorial and i'm stuck on counting points. I followed the destroy by contact script letter by letter and i'm still getting an error saying "The namespace GameController cannot be found" Any help is appreciated and the sooner the better.
     

    Attached Files:

  9. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    1) Please double check you have a script called GameController in your project.
    2) Make sure you are using the correct script, NOTHING from the "_Complete-Game" directory
     
  10. pablothetacoman1812

    pablothetacoman1812

    Joined:
    Sep 25, 2017
    Posts:
    5
    Yes i have a script I made myself named "GameController"
     
  11. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    I'll assume you closed out of Unity and restarted and continue to get the problem

    1 Make sure there are no build or execution errors in the console log

    2 Make sure your GameController script class name is spelled and punctuated correctly (GameController, no space or undersore)
    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.UI;
    6. using UnityEngine.SceneManagement;
    7.  
    8.  
    9. public class GameController : MonoBehaviour {
    10.     public GameObject[] hazards;
    11. ...
    12.  
    3 Sometimes, by accident, scripts are used/modified/referenced that are in the "_Complete-Game" directory. So, I would move that directory completely out of the Unity directory. Using filemanager (with Unity closed down), move ...\Unity Projects\SpaceShooter\Assets\_Complete-Game to c:\temp (just the "_Complete-Game" directory)

    4 Could you show you project & hierarchy from inspector
    upload_2017-10-18_17-6-56.png
     
  12. electr0kewt

    electr0kewt

    Joined:
    Oct 11, 2017
    Posts:
    4
    Hey @gwnguy That helped a lot! Its not perfect yet, but turns out my Mover script's speed was set to 5 and not -5. My Asteroids also sometimes destroy themselves even when they are not touching anything. So I made my collider shape smaller to see if that would help but no avail. Any advice in that regard? Thank you so much mr!
     
  13. carbonitium

    carbonitium

    Joined:
    Oct 18, 2017
    Posts:
    3
    On all that is HOLY!
    I just needed to shout that out; made the damned thing work for doubled shots!
    At part 7 I started to think I really want to try and understanding coding, so I figured, my aim is to have my ship shoot twin-bolts.
    And I had no idea it will make me scratch my head so hard even though I used to script in Powershell (nothing serious).
    But if anyone want to experiment as well, below is the code that did the trick for me:
    upload_2017-10-19_12-51-15.png

    Something that still bothers me is, why wouldn't it accept a '&&' connector between two Instantiate expressions?

    [edit]
    Spotted an error with GameObject clone = (didn't notice it got commented out in the video) so that seems to work without any errors now :)
     
    Last edited: Oct 19, 2017
  14. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    heh, nice. I had made a similar mod to mine. I instantiated a bolt on the left wing and on the right wing.
    The, if the first time the ship was hit, instead of being destroyed, it simply disabled the added guns.
    The second time the ship was hit, it was destroyed.
    Code (csharp):
    1.  
    2.     private void Update()
    3.     {
    4.         if ((Input.GetButton("Fire1") || Input.GetKeyDown("space")) && Time.time > nextFire)
    5.         {
    6.             nextFire = Time.time + fireRate;
    7.             GameObject c = Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
    8.             c.tag = "GunCenter";
    9.             GetComponent<AudioSource>().Play();
    10.  
    11.             if (iplayerHits < 1)
    12.             {
    13.                 GameObject r = Instantiate(shot, new Vector3(shotSpawn.position.x - .58f, shotSpawn.position.y, shotSpawn.position.z - .55f), shotSpawn.rotation);
    14.                 r.tag = "GunRight";
    15.                 GameObject l =Instantiate(shot, new Vector3(shotSpawn.position.x + .58f, shotSpawn.position.y, shotSpawn.position.z - .55f), shotSpawn.rotation);
    16.                 l.tag = "GunLeft";
    17.             }
    18.  
    19.         }
    20.     }
    21.  
    22.  
    Another mod I made was to not clamp the ship, but instead allow it to scroll off one side and onto the other.
    Code (csharp):
    1.  
    2.     void FixedUpdate()
    3.     {
    4.         float moveHorizontal = Input.GetAxis("Horizontal");
    5.         float moveVertical = Input.GetAxis("Vertical");
    6.  
    7.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    8.         GetComponent<Rigidbody>().velocity = movement * speed;
    9.  
    10.         /*
    11.         GetComponent<Rigidbody>().position = new Vector3
    12.             (Mathf.Clamp(GetComponent<Rigidbody>().position.x, boundary.xMin, boundary.xMax),
    13.              0.0f,
    14.              Mathf.Clamp(GetComponent<Rigidbody>().position.z, boundary.zMin, boundary.zMax));
    15.              */
    16.  
    17.         Vector3 qq = GetComponent<Rigidbody>().position;
    18.         if (qq.x < boundary.xMin) qq.x = boundary.xMax - .01f;
    19.         if (qq.x > boundary.xMax) qq.x = boundary.xMin + .01f;
    20.         if (qq.z < boundary.zMin) qq.z = boundary.zMax - .01f;
    21.         if (qq.z > boundary.zMax) qq.z = boundary.zMin + .01f;
    22.         GetComponent<Rigidbody>().position = qq;
    23.  
    24.         GetComponent<Rigidbody>().rotation = Quaternion.Euler(0.0f, 0.0f,
    25.             GetComponent<Rigidbody>().velocity.x * -tilt);
    26.     }
    27.  
    This game had some nice modifiable features if so desired.
     
  15. pablothetacoman1812

    pablothetacoman1812

    Joined:
    Sep 25, 2017
    Posts:
    5
    Screenshot (1).png
     
  16. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    Please verify your GameController object has the tag: GameController
    upload_2017-10-19_17-18-13.png


    Please Make sure there are no build or execution errors in the console log
    The namespace error you are seeing is sometimes caused by compile/build errors in the script (GameController.cs in this case)


    If that doesn't work, please post your GameController.cs script
     
    Last edited: Oct 20, 2017
  17. carbonitium

    carbonitium

    Joined:
    Oct 18, 2017
    Posts:
    3
    Hah, true that. It's a nice little playground to tinker with.
    I like the idea of "teleporting" from side-to-side.
    Still, keeping my fingers crossed to get explanation why wouldn't C# eat up my '&&' in this particular place.
    I understand why it might be redundant, but I don't get the logic for NOT accepting it while 'and' operator is implied anyway.
    And 2 further questions that bother me still;
    1. How would you go about having wave counter text displayed only between the waves?
    2. With scripts done 95% per tutorial, text for restart (and feature itself) are not active until all enemies from given wave finish spawning and get destroyed by, either the limiting boundary or time. Doesn't matter really.
    My spawn waves look like below and I failt to understand why the hell is it waiting for all spawned enemies to die off before showing the text for restart?
    Code (csharp):
    1.  
    2. IEnumerator SpawnWaves()
    3.     {
    4.         yield return new WaitForSeconds(startWait);
    5.         while (true)
    6.         {
    7.             for (int i = 0; i < hazardCount; i++)
    8.             {
    9.                 GameObject hazard = hazards[Random.Range (0, hazards.Length)];
    10.                 Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
    11.                 Quaternion spawnRotation = Quaternion.identity;
    12.                 Instantiate(hazard, spawnPosition, spawnRotation);
    13.                 yield return new WaitForSeconds(spawnWait);
    14.             }
    15.             yield return new WaitForSeconds(waveWait);
    16.             waveCount += 1;
    17.             hazardCount += 3;
    18.             if (gameOver)
    19.             {
    20.                 restartText.text = "hit 'r' to restart";
    21.                 restart = true;
    22.                 break;
    23.             }
    24.         }
    25.     }
    26.  
    Whole GameController script below is someone would like to give me any pointers.
    Coding babysteps are painful :<
    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.UI;
    6. using UnityEngine.SceneManagement;
    7.  
    8. public class GameController : MonoBehaviour
    9. {
    10.     public GameObject [] hazards;
    11.     public Vector3 spawnValues;
    12.     public int hazardCount;
    13.     public int waveCount;
    14.     public float spawnWait;
    15.     public float startWait;
    16.     public float waveWait;
    17.     public Text waveNumber;
    18.     public Text scoreText;
    19.     public Text restartText;
    20.     public Text gameOverText;
    21.  
    22.     private bool gameOver;
    23.     private bool restart;
    24.     private int score;
    25.  
    26.     private void Start()
    27.     {
    28.         gameOver = false;
    29.         restart = false;
    30.         restartText.text = "";
    31.         gameOverText.text = "";
    32.         waveCount = 1;
    33.         score = 0;
    34.         UpdateScore();
    35.         StartCoroutine(SpawnWaves());
    36.     }
    37.     private void Update()
    38.     {
    39.         if (restart)
    40.         {
    41.             if (Input.GetKeyDown(KeyCode.R))
    42.             {
    43.                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    44.             }
    45.            
    46.         }
    47.         waveNumber.text = "Wave " + waveCount;
    48.     }
    49.     IEnumerator SpawnWaves()
    50.     {
    51.         yield return new WaitForSeconds(startWait);
    52.         while (true)
    53.         {
    54.             for (int i = 0; i < hazardCount; i++)
    55.             {
    56.                 GameObject hazard = hazards[Random.Range (0, hazards.Length)];
    57.                 Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
    58.                 Quaternion spawnRotation = Quaternion.identity;
    59.                 Instantiate(hazard, spawnPosition, spawnRotation);
    60.                 yield return new WaitForSeconds(spawnWait);
    61.             }
    62.             yield return new WaitForSeconds(waveWait);
    63.             waveCount += 1;
    64.             hazardCount += 3;
    65.             if (gameOver)
    66.             {
    67.                 restartText.text = "hit 'r' to restart";
    68.                 restart = true;
    69.                 break;
    70.             }
    71.         }
    72.     }
    73.  
    74.     public void AddScore(int newScoreValue)
    75.     {
    76.         score += newScoreValue;
    77.         UpdateScore();
    78.     }
    79.     void UpdateScore()
    80.     {
    81.         scoreText.text = "" + score;
    82.     }
    83.     public void GameOver()
    84.     {
    85.         gameOverText.text = "game over!";
    86.         gameOver = true;
    87.     }
    88. }
    89.  
    90.  
     
  18. pablothetacoman1812

    pablothetacoman1812

    Joined:
    Sep 25, 2017
    Posts:
    5
    Ok well i fixed it but now no astroids are spawning
     
  19. Aiku1337

    Aiku1337

    Joined:
    Oct 19, 2017
    Posts:
    2
    I hope I'm not asking something that has been answered a lot. I've tried using the search feature for this thread but can't find an answer.

    I'm using the latest beta of Unity 2017 and cannot get the explosion particles to display at all. Asteroid, player, or enemy do not display. The engine particles work fine. To test, I'm just adding the particles to the scene at origin and clicking the play particle button. Nothing is displayed.

    Any help would be appreciated!
     
  20. CheekyCharlie1978

    CheekyCharlie1978

    Joined:
    Oct 20, 2017
    Posts:
    7
    Guess I will rewrite it instead....


    Hello there fellow Unity Developers, I have found myself stuck on a problem where I cannot figure out what I have missed to make the Player and Asteroid collide and create an explosion, the Player simply flies through the Asteroid instead of colliding with it

    I have checked over everything I can think of to see if there is some piece of code I have missed out but cannot find anything wrong, so thought I may be able to get some help with it here

    I would expect, if anything, it would be my DestroyByContact.cs that would need adjusting, so here is the code I have written and taken from the Tutorial video:

    2. Boundaries, Hazards and Enemies - Explosions [I am currently at 2:43 in]

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class DestroyByContact : MonoBehaviour
    {

    public GameObject explosion;
    public GameObject playerExplosion;

    void OnTriggerEnter(Collider other)
    {
    if (other.tag == "Boundary")
    {
    return;
    }
    Instantiate(explosion, transform.position, transform.rotation);
    if (other.tag == "Player")
    {
    Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
    }
    Destroy(other.gameObject);
    Destroy(gameObject);
    }
    }


    If it isn't something here i'm lost as to what it could be, the above code is written exactly as found in the tutorial, so unless it's slightly outdated code that the Tutorial Update doesn't show changes for colour me stupified
     
    Last edited: Oct 21, 2017
  21. CheekyCharlie1978

    CheekyCharlie1978

    Joined:
    Oct 20, 2017
    Posts:
    7
    PS. I have no errors show up in the console for any script so far, everything previous to this works perfectly as intended too and I highly doubt I have accidentally changed a parameter in the inspector for anything.

    I am also using Unity version 2017.1.1f1 if that helps
     
  22. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    It may not be the code. Please verify the gameobjects (player and asteroid) are set up correctly.
    Especially tags and colliders

    upload_2017-10-21_11-42-21.png

    Thanks for mentioning your console.log has no errors
     
  23. Aiku1337

    Aiku1337

    Joined:
    Oct 19, 2017
    Posts:
    2
    The code looks fine to me but if it flies though the Asteroid maybe one or the other does not have a collider attached to it?

    Also check that your player asset has the Player tag associated with it.
     
  24. CheekyCharlie1978

    CheekyCharlie1978

    Joined:
    Oct 20, 2017
    Posts:
    7
    Thank you for your response Aiku1337, having checked through the video's again I found that the problem was indeed with the "Player" Mesh Collider set to unchecked

    Hopefully this will teach me to take greater care in the future
     
    Last edited: Oct 22, 2017
  25. CheekyCharlie1978

    CheekyCharlie1978

    Joined:
    Oct 20, 2017
    Posts:
    7
    I am currently working my way through the Extending Space Shooter Tutorial using Unity 2017.1.1f1, at the 1:07:00 mark within the Tutorial, at the point of testing if the Enemy Ship shoots and destroys my Player Ship

    The problem I am having is that while testing, I found that upon shooting an Asteroid, the Enemy Ship, or it's Bolt, my Game Over text appears and the game ends unexpectedly

    I have followed this tutorial precisely and while the guy on the tutorial doesn't have any issue's when he shoots an Asteroid, I unfortunately do and rather than simply continue with the tutorial, logic dictates this error needs fixing first

    My initial thoughts are that yet again, the tutorial has made some kind of mess of things as it was made for Unity v5.2, not Unity 2017.1.1f1 and that it could also have something to do with creating the "Enemy" Tag and adding it to the Asteroids and Enemy Ship

    Any assistance with this issue would be greatly appreciated, I have tried searching through the Q & A Section but found nothing related to my issue as yet and do not wish to waste any more time than absolutely necessary to complete this tutorial

    I can provide code snippets and Inspector Images for anything you may need to see/check over, also, there are no Console errors

    Just to update with the solution incase anyone else has this issue----

    ----I found the problem myself on the DestroyByContact script, when the guy in the Tutorial changed the original code from

    if (other.Tag == "Boundary")

    to

    if (other.CompareTag ("Boundary") || other.CompareTag ("Enemy")

    he also changed (or commented that the same could be done for)

    if (other.tag == "Player") to if (other.CompareTag)


    simply changing the compareTag back to other.Tag for Player fixed the issue
     
    Last edited: Oct 23, 2017
  26. SpadGame

    SpadGame

    Joined:
    Sep 7, 2017
    Posts:
    7
    I need help! I'm stuck on the Moving the Player tutorial. I've put in all the code and all I get is an error!
    The error is: Assets/Scripts/PlayerController.cs(4,0): error CS1525: Unexpected symbol `Rigidbody'
     
  27. CheekyCharlie1978

    CheekyCharlie1978

    Joined:
    Oct 20, 2017
    Posts:
    7
    as is shown in the Update and also on the tutorial video [if you turn on annotations] newer versions of Unity use Rigidbody in a different manner, without going into that [as you can find this information yourself, as referenced above] the code you need to write for Mover.cs is now as follows:

    using UnityEngine;
    using System.Collections;

    public class Mover : MonoBehaviour
    {
    public float speed;

    private Rigidbody rb;

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

    unity_iUvEAdmUOVbIZw

    Joined:
    Oct 23, 2017
    Posts:
    2
    I need help! I can't get my laser to shoot no matter what button I press
    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;

    [System.Serializable]
    public class Boundary
    {
    public float xMin, xMax, zMin, zMax;
    }
    public class PlayerController : MonoBehaviour
    {
    public float speed;
    public float tilt;
    public Boundary boundary;

    public GameObject shot;
    public Transform shotSpawn;
    public float fireRate;

    private float nextFire;


    void update ()
    {
    if (Input.GetButton("Fire1") && Time.time > nextFire)
    {
    nextFire = Time.time + fireRate;
    Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
    GetComponent<AudioSource>().Play ();
    }
    }

    void FixedUpdate ()
    {
    float moveHorizontal = Input.GetAxis ("Horizontal");
    float moveVertical = Input.GetAxis ("Vertical");

    Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    GetComponent<Rigidbody>().velocity = movement * speed;

    GetComponent<Rigidbody>().position = new Vector3
    (
    Mathf.Clamp (GetComponent<Rigidbody>().position.x, boundary.xMin, boundary.xMax),
    0.0f,
    Mathf.Clamp (GetComponent<Rigidbody>().position.z, boundary.zMin, boundary.zMax)
    );
    GetComponent<Rigidbody>().rotation = Quaternion.Euler (0.0f, 0.0f, GetComponent<Rigidbody>().velocity.x * -tilt);
    }
    }

    I even went on the input settings to see if i can change the buttons but nothing changed. Please help
     
  29. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    At line 24 it says
    void update ()
    Capitalize the u so it says
    void Update ()
     
    jeremyr likes this.
  30. unity_iUvEAdmUOVbIZw

    unity_iUvEAdmUOVbIZw

    Joined:
    Oct 23, 2017
    Posts:
    2
    Thank you soooooooooooooooooooooooooooooooooooooooooooo much! I feel so not smart right now
     
  31. SpadGame

    SpadGame

    Joined:
    Sep 7, 2017
    Posts:
    7
    Thank you so much! I was having so much trouble with this!
     
  32. MrPaulRI

    MrPaulRI

    Joined:
    Oct 26, 2017
    Posts:
    1
    Was having problems playing weapon_player clip using audio.Play() and found the solution here: https://docs.unity3d.com/ScriptReference/AudioSource.Play.html

    Much like Rigidbody you must get the Audio Source component from the Game Object before calling a method on it.

    Hopes this helps anyone else who gets stuck!
     
    Last edited: Oct 26, 2017
    gr8crE8r and ichthyne343 like this.
  33. bgmsd1

    bgmsd1

    Joined:
    Feb 8, 2016
    Posts:
    3
    I am using Unity 2017.2. I I am trying to reference the UI Text object in code so that I can update the score. In my opinion, the best place to do this in the DestroyByContact script becasue it is attached to the asteroid. So I think the logic should be that if the object that makes contact with the asteroid is a Bolt, then add 10 to the score and update the text property of the Text object.

    The problem is that when I write Public Text scoreText; at the class level of DestroyByContact, I get an error that the name Text does not exist in the current context. Please see the screen shot.

    I created the Text object from the Hierarchy window. I selected Create > UI > Text. Text is a child of Canvas. So how do I reference this Text object in my script and update the text property?


    UPDATE: I figured it out. I watched the Roll A Ball Tutorial which also displays the score. I needed to add "using UnityEngine.UI;" to the GameController class. The UnityEngine.UI namespace holds the Text class.
     

    Attached Files:

    Last edited: Oct 27, 2017
  34. JTS_Studios

    JTS_Studios

    Joined:
    Oct 26, 2017
    Posts:
    1
     
  35. rienheuver

    rienheuver

    Joined:
    Oct 24, 2017
    Posts:
    2
    I'm having a "bug", though it's kinda good functionality. Namely that the bug addressed when creating the OnColliderEnter function on Asteroid, is not present with me. The bug is that the asteroid and the boundary are destroyed because the OnColliderEnter is triggered. However, for me they both exist just fine, even though I haven't implemented the bug-fix yet. Why is this? With an extensive programming background I can understand why Unity might have changed their engine so this trigger isn't called anymore. But that might not be the case and I might have done something wrong :p. So any explanation would be awesome. (As far as I can tell I followed up with the tutorial just fine, I can destroy asteroids by shooting bolts just fine.)
     
  36. g4mdev

    g4mdev

    Joined:
    Sep 17, 2017
    Posts:
    1
    I have amended my game controller script to include an int for counting waves and spawning different hazards as the int increases. I have the co routine restarting when the wave reaches a certain value but i want the int to reset back to zero when the co routine restarts. Currently it restarts the co routine but also spawns the hazed from the last part of the co routine each time.
     
  37. 0neManArmy

    0neManArmy

    Joined:
    Apr 4, 2014
    Posts:
    4
    Well I have this problem qhen creating a wave, in the video when many asteroids are created at once they enter in contact with each other and then, they are destroyed by contact, but in my case I get this strange behaviour, all the asteroids start to fly away off the gameplay zone instead of being destroyed by contact in case they touch with other thing, like this:

    upload_2017-10-28_19-17-44.png

    So what is wrong with my project??? I've been following the tutorial step by step but i get this strange behaveiour, please help....
     
  38. LelandGreen

    LelandGreen

    Joined:
    Oct 6, 2017
    Posts:
    13
    How would you (and everyone) like an example of taking the initial tutorial (i.e., no enemies) into a fully 3D game? I trudged through the tutorial and figured things out enough to get it working. (How many have done that lately? Seriously?)

    I also made it into a VR game! :cool:The score isn't showing up in VR, yet, but I hope to have that soon. But even just the way it is, it's a lot of fun to play it! :cool:

    If anyone is interested I'm sure I could be persuaded to post on GitHub. Providing that's OK with everyone, of course. :)
     
    bertenernie likes this.
  39. LelandGreen

    LelandGreen

    Joined:
    Oct 6, 2017
    Posts:
    13
    OK, I've just made a commit to a public repository. I reached a title of Software Engineer, Advanced. However, I've never done much game coding since the Commodore 64 days. Just took this up as a hobby in retirement.

    I'm happy to share my progress with everyone. Beware that I've drastically modified both the code and the configurations, compared to the default game. After all, it's now a full-blown 3D Space Shooter that will even run in VR! (And is really meant for that.) But you can use it as a learning tool, even if you don't have VR.

    It's still rough around the edges, but I hope it helps someone.

    https://bitbucket.org/LelandGreen/space-shooter-vr

    Comments, anyone? :)
     
  40. BashiDono

    BashiDono

    Joined:
    Oct 23, 2017
    Posts:
    3
    So I'm having a problem where whenever I enter the game it sets off an initial shot without me clicking anything, what could be wrong? Also, how do I change it so instead of shooting with the mouse I change it to the space bar?

    My Code is:
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. [System.Serializable]
    6. public class Boundry
    7. {
    8.     public float xMin, xMax, zMin, zMax;
    9. }
    10.  
    11. public class PlayerController : MonoBehaviour
    12. {
    13.     public Rigidbody rb;
    14.     public float speed;
    15.     public float tilt;
    16.     public Boundry boundry;
    17.  
    18.     public GameObject shot;
    19.     public Transform shotSpawn;
    20.     public float fireRate;
    21.  
    22.     private float nextFire;
    23.  
    24.     void Start()
    25.     {
    26.         rb = GetComponent<Rigidbody>();
    27.     }
    28.  
    29.     void Update()
    30.     {
    31.         if (Input.GetButton("Fire1") && Time.time>nextFire)
    32.         {
    33.             nextFire = Time.time + fireRate;
    34. //          GameObjest close =
    35.             Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
    36.         }
    37.      
    38.     }
    39.  
    40.     void FixedUpdate()
    41.     {
    42.         float moveHorizontal = Input.GetAxis("Horizontal");
    43.         float moveVertical = Input.GetAxis("Vertical");
    44.  
    45.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    46.  
    47.         rb.velocity = movement * speed;
    48.  
    49.         rb.position = new Vector3
    50.             (
    51.                 Mathf.Clamp (rb.position.x, boundry.xMin, boundry.xMax),
    52.                 0.0f,
    53.                 Mathf.Clamp (rb.position.z, boundry.zMin, boundry.zMax)
    54.             );
    55.  
    56.         rb.rotation = Quaternion.Euler(0.0f, 0.0f, rb.velocity.x * -tilt);
    57.  
    58.     }
    59. }
    [Please use code tags when posting code - Mod]
     
    Last edited by a moderator: Nov 9, 2017
  41. TwinsMakeGames

    TwinsMakeGames

    Joined:
    Aug 10, 2017
    Posts:
    2
    Since the tutorial video isn't updated, I'm having issue with the GUItext score system, Unity said that Guitext is Legacy or something.Please I need help
     
  42. LelandGreen

    LelandGreen

    Joined:
    Oct 6, 2017
    Posts:
    13
    Use simply Text instead of GUIText. At least that's what I did. :cool:
     
  43. absticles

    absticles

    Joined:
    Oct 24, 2017
    Posts:
    1
    I am having the same problem... I am using

    public Text scoreText;​

    However, it doesn't seem to recognise it...

    Assets/Scripts/GameController.cs(13,9): error CS0246: The type or namespace name `Text' could not be found. Are you missing `UnityEngine.UI' using directive?

    *** Just solved this, you need to include this at the top of your script...

    using UnityEngine.UI;​
     
    LelandGreen likes this.
  44. TwinsMakeGames

    TwinsMakeGames

    Joined:
    Aug 10, 2017
    Posts:
    2
    So, I need to go to UI then text?
     
  45. E_Shaw

    E_Shaw

    Joined:
    Nov 1, 2017
    Posts:
    1
    I am having a problem using Microsoft Visual Studio. It is not recognizing "moveHorizontal" and i'm not sure what to do.
     
  46. Gauntlit

    Gauntlit

    Joined:
    Nov 1, 2017
    Posts:
    5
    Hey guys.

    Just a quick question about Ambient lighting ..In Video 3--the one with camera and lighting-- the video directs me to go to Edit and Render settings to access Ambient lighting options.

    The Caption, however, tells me to go to "Window" then "ligihting"

    However, I have access both options under the "lighting" tab (as seen in the two panels in the screenshot)

    And NEITHER of them are the ambient lighting options (Or maybe they are?)

    Anyway, a little help figuring out how to find the ambient lighting options would be great. Thanks.
     

    Attached Files:

  47. rhaithe

    rhaithe

    Joined:
    Oct 27, 2017
    Posts:
    4
    Another great project!

    Thank you so much for including the finished project. I really enjoyed following along with the tutorials, but especially enjoyed not having to tab back and forth to create everything as I went.

    I learned a great deal from this one. Looking forward to more!!!
     
    Numbat17 likes this.
  48. wmmayfield

    wmmayfield

    Joined:
    Nov 2, 2017
    Posts:
    18

    Attached Files:

    Last edited: Nov 3, 2017
  49. Tatertot1

    Tatertot1

    Joined:
    Nov 3, 2017
    Posts:
    1
    I am having the same problem. My ship's y value jumps to 2.33.
     
  50. LelandGreen

    LelandGreen

    Joined:
    Oct 6, 2017
    Posts:
    13
    Is fireRate set in the instance (in the IDE)? If it's 0, I think it would cause that.

    It should fire when you click the mouse, already. But change all this in Edit->Project Settings->Input. (You can also get to it from the Build Settings->Input.)