Search Unity

Space Shooter Tutorial Q&A

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

  1. DrakUnlimited

    DrakUnlimited

    Joined:
    Jul 5, 2017
    Posts:
    10
    Annotation needs to be added for video 3.4 (Building the game) for the newer WebGL (instead of Web Player)
     
  2. daveshan

    daveshan

    Joined:
    Jul 6, 2017
    Posts:
    1
    I need help with the additional things during the Live Training 8th December 2014 Mobile Development for this game.

    The touch controls aren't working. The bolt will fire, but the ship doesn't move. Here's what I have

    https://gist.github.com/anonymous/c8b06e196d7f5faf89232bc98bc2bd0a

    EDIT: I figured out part of the problem, I didn't assign movement zone to the player object. However, now I'm getting a whole new problem. Some people through the thread have had the problem of they can't fire and move at the same time. I just can't move. Even with movement zone assigned to the player object and the SimpleTouchPad assigned to movement zone, I cannot move my ship at all.

    Also, there's no error or bug report being given.
     
    Last edited: Jul 6, 2017
    tiwanaku322 likes this.
  3. DrakUnlimited

    DrakUnlimited

    Joined:
    Jul 5, 2017
    Posts:
    10
    BEST GUESS:
    Few things to check:
    1) Make sure you have a little wait time before evasion starts, as the vector3 in the co-routine COULD set the velocity to zero, since the rigidbody's initial velocity is zero. This is VERY unlikely, but easy to check.

    2) Make sure your line EvasiveManeuver -> FixedUpdate is as follows:
    (specifically that the 3rd parameter is the ship's current velocity
    Code (csharp):
    1.  
    2.         rb.velocity = new Vector3(newManeuver,0.0f,rb.velocity.z);
    3.  
    IN MY MIND, this is better than setting it at Start, and using the start value since the start CAN be called before the mover script initializes the velocity, resulting in an initialized value of 0 in your variable, which then resets the ship's velocity.

    Instead, IN MY OPINION it's much better to just keep the ship's current velocity. This doubly adds the ability to change a ship's z-axis velocity elsewhere in code/over time and the evasion won't overwrite those changes made elsewhere.

    PS: This also removes the possibility of issue 1 above, as the Mover script can apply its velocity change AFTER the Evasion script starts and still have an effect (and not get reset by the evasion script).

    3) Make sure your ships aren't just WAY WAY off screen, easiest way to do this is to play, then pause once you see an enemy bolt (so you know there's an enemy) then click the instance of the enemy in the hierarchy and check its position values to make sure they "make sense" (I believe in this tutorial the zed position should be around 8, but I can't remember for sure, check one of the asteroids near the top maybe, and just check that both have "close" position.z values.)

    4) Make sure the enemy ships are flying in the correct direction (you can see this by selecting the ship in the play mode, and watching its position.z value - if it's getting larger, your ship is flying in the wrong direction, check: the speed property has the right sign (negative or positive), the ship prefab has a 180 degree rotation, etc.)

    Best of luck!
     
    Last edited: Jul 7, 2017
    tiwanaku322 likes this.
  4. DrakUnlimited

    DrakUnlimited

    Joined:
    Jul 5, 2017
    Posts:
    10
    Tutorial Completed in v5.6.2f1 with the few comments made above about issues with scene manager, audio file drag and drops, and the WebGL player.

    (Including the extended enemy tutorial, not including the mobile release)
     
  5. MarkMcClouds

    MarkMcClouds

    Joined:
    Sep 1, 2016
    Posts:
    3
    Hi, I am having an issue with my Asteroid. I got to the part in the lesson DestroyByTime. Everything works fine except the part when my asteroids leave the screen. It doesn't remove the asteroid from the Hierarchy. All asteroids that I don't shoot with just pile up in the Hierarchy. When I am in scene mode watching the game play there is no explosion when the asteroid touches the boundary. is that the problem? Please help.
     
  6. DrakUnlimited

    DrakUnlimited

    Joined:
    Jul 5, 2017
    Posts:
    10
    Destroying off screen hazards is handled in lesson 2.1, and the DestroyByBoundary script.
     
  7. MarkMcClouds

    MarkMcClouds

    Joined:
    Sep 1, 2016
    Posts:
    3
    EDIT: I forgot to add a Capsule Collider to my Asteroid. everything works fine.
     
  8. JoniBerg

    JoniBerg

    Joined:
    Jun 30, 2017
    Posts:
    14
    Why my bolts not destroyed asteroid?
    Code (CSharp):
    1. public class DestroyByContact : MonoBehaviour {
    2.  
    3.     void onTriggerEnter(Collider other) {
    4.      
    5.         if (other.gameObject.name == "Boundary") {
    6.             Debug.Log ("Finding Boundaries");
    7.  
    8.             {
    9.                 return;
    10.             }
    11.             Debug.Log ("Started Execute.");
    12.  
    13.             Destroy(other.gameObject);
    14.             Destroy(gameObject);
    15.         }
    16.             Debug.Log ("Destroyed Astroid/Bolts.");
    17.         }
    18. }
    19.  
    Don't debug "started execute" never. In editor.

    My Unity version is 5.4.1.

    Thanks for answer.
     
  9. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    There are at least 3 problems.

    1) Capitalize the o of the method name onTriggerEnter at line 3 to be:
    Code (csharp):
    1.  void OnTriggerEnter(Collider other)
    2) check tag, not name at line 5
    Code (csharp):
    1.  
    2. // no, this is incorrect:   if (other.gameObject.name == "Boundary") {
    3. if (other.tag == "Boundary") {
    4.  
    3) small, nit pick- you don't need the curly braces (lines 8 and 10) around the return at line 9. delete them
    Code (csharp):
    1.  
    2.             Debug.Log ("Finding Boundaries");
    3.             return;
    4.  
    4) I think you may have misplaced a curly. Line 15 should be under line 10.
    Try this:
    Code (csharp):
    1.  
    2. public class DestroyByContact : MonoBehaviour {
    3.  
    4.     void OnTriggerEnter(Collider other) {
    5.  
    6.        if (other.tag == "Boundary") {
    7.             Debug.Log ("Finding Boundaries");
    8.             return;
    9.             }   // this is the closing brace for   if (other.tag == "Boundary")
    10.  
    11.        Debug.Log ("Started Execute.");
    12.        Destroy(other.gameObject);
    13.        Destroy(gameObject);
    14.        Debug.Log ("Destroyed Asteroid Bolts.");
    15.  
    16.    }   // this is the closing brace for  void OnTriggerEnter(Collider other)
    17.  
    18.  }   // this is the closing brace for  public class DestroyByContact : MonoBehaviour
    19.  
    (BTW- I'm not sure if the actual code is correct, it's pretty much just a rewrite of what you had)
     
    Last edited: Jul 10, 2017
  10. gamer241

    gamer241

    Joined:
    Jul 11, 2017
    Posts:
    1
    Hi i was just wondering if there any plans to make a new tutorial Vid because many action taken in tutorial are deprecated like rigidbody for example and because of that i can't finish the game.
     
    gr8crE8r likes this.
  11. HectorOfPriamos

    HectorOfPriamos

    Joined:
    Jul 9, 2017
    Posts:
    15
    Hello,

    I'm new to Unity and as you can guess I was just hanging out with Space Shooter tutorial. I had some difficulties with adapting the changes between old and new Unity. But the issue I experince now is quite strange and I appreciate any help. My asteroids are moving in 3 dimension instead of only on z axis.

    I'm including the code snippet below:

    Code (CSharp):
    1. public class GameController : MonoBehaviour {
    2.  
    3.     public GameObject hazard;
    4.     public Vector3 spawnValues;
    5.     public int hazardCount;
    6.  
    7.     // Use this for initialization
    8.     void Start () {
    9.         SpawnWaves ();
    10.     }
    11.     void SpawnWaves()
    12.     {
    13.         for(int i = 0; i < hazardCount; i++){
    14.             Vector3 spawnPosition = new Vector3 (Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
    15.             Quaternion spawnRotation = Quaternion.identity;
    16.             Instantiate (hazard, spawnPosition, spawnRotation);
    17.         }
    18.     }
    19.        
    20. }
    21.  
    22.  
    When I run this code asteroids start moving in all directoins so this is not good for a 2D game :confused: However whn I comment the for loop and remain all other lines same like this:

    Code (CSharp):
    1. public class GameController : MonoBehaviour {
    2.  
    3.     public GameObject hazard;
    4.     public Vector3 spawnValues;
    5.     public int hazardCount;
    6.  
    7.     // Use this for initialization
    8.     void Start () {
    9.         SpawnWaves ();
    10.     }
    11.     void SpawnWaves()
    12.     {
    13.     //    for(int i = 0; i < hazardCount; i++){
    14.             Vector3 spawnPosition = new Vector3 (Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
    15.             Quaternion spawnRotation = Quaternion.identity;
    16.             Instantiate (hazard, spawnPosition, spawnRotation);
    17. //        }
    18.     }
    19.        
    20. }
    21.  
    22.  
    Then my asteroid (only one is generated) moves only on z axis onto my spaceship. Can anybody see what is the problem with the for loop? Why adding this for loop causes asteroids to move in three dimension?

    Thanks in advance!
     
  12. JoniBerg

    JoniBerg

    Joined:
    Jun 30, 2017
    Posts:
    14
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DestroyParticleSystem : MonoBehaviour
    5. {
    6.  
    7.     public GameObject explosion;
    8.     public GameObject playerExplosion;
    9.     public int ScoreValue;
    10.  
    11.     private GameObject gameControllerObject;
    12.     private GameController gameController;
    13.  
    14.  
    15.  
    16.     void Start ()
    17.     {
    18.         GameObject gameControllerObject = GameObject.Find ("GameController");
    19.         if (gameControllerObject != null)
    20.      
    21.         {
    22.             Debug.Log ("GameController Script not fount");
    23.         }
    24.  
    25.  
    26.     }
    27.  
    28.      // Avoided Boundary collider.
    29.     void OnTriggerEnter(Collider other)
    30.     {
    31.         if (other.tag == "Boundary")
    32.         {
    33.             return;
    34.         }
    35.  
    36.             // Asteroid destroyed.
    37.  
    38.          Instantiate (explosion,transform.position,transform.rotation);
    39.  
    40.             // Player destroyed.
    41.         if (other.name == "Player"){
    42.             Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
    43.         }
    44.         // This is my problem guys. ***
    45.         gameController.AddScore (ScoreValue);
    46.         Destroy (other. gameObject);
    47.         Destroy (gameObject);
    48.         //*****    
    49.         }
    50.  
    51.  
    52.  
    53. }
    54.  
    55.  

    I Don't show my Score. Why? Destroyed asteroid and go to out Play mode. Problem is on 45. line.

    And these Message on the Console >>> "Default GameObject Tag: GameController already registered."

    What is solved?
     
  13. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    I don't think you actually got a hold of the gameController in your Start method.

    Replace the current Start method with the following:
    Code (csharp):
    1.  
    2.     void Start()
    3.     {
    4.         GameObject gameControllerObject = GameObject.FindGameObjectWithTag("GameController");
    5.         if (gameControllerObject != null)
    6.         {
    7.             gameController = gameControllerObject.GetComponent<GameController>();
    8.         }
    9.         if (gameController == null)
    10.         {
    11.             Debug.Log("Cannot find 'GameController' script");
    12.         }
    13.     }
    14.  
     
  14. JoniBerg

    JoniBerg

    Joined:
    Jun 30, 2017
    Posts:
    14
    Yeah now working. :) Thanks my finding script was error on Start method.
     
  15. JoniBerg

    JoniBerg

    Joined:
    Jun 30, 2017
    Posts:
    14
    My Restart Game not working any ideas?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine.UI;
    5. using UnityEngine.SceneManagement;
    6.  
    7. public class GameController : MonoBehaviour {
    8.  
    9.  
    10.     // Create Variables.
    11.  
    12.     public Text ScoreText;
    13.     public Text RestartText;
    14.     public Text GameOverText;
    15.  
    16.     private bool GameOver;
    17.     private bool Restart;
    18.     private int Score;
    19.     private Vector3 SpawnPosition;
    20.     private Quaternion SpawnRotation;
    21.  
    22.  
    23.  
    24.     void Start()
    25.     {
    26.  
    27.         // Created Score.    // Created also game Restart/GameOver operation.
    28.  
    29.         Restart = false;
    30.         GameOver = false;
    31.         RestartText.text = "";
    32.         GameOverText.text = "";
    33.         Score = 0;
    34.         StartCoroutine (SpawnWaves ());
    35.  
    36.     }
    37.  
    38.     void Update()
    39.     {
    40.         if(Restart)
    41.         {
    42.             if (Input.GetKeyDown (KeyCode.R))
    43.             {
    44.            
    45. //Application.Equals(SceneManager.GetActiveScene().name);
    46.                 //(SceneManager.GetActiveScene ().name);
    47.                 //Scene scene = SceneManager.GetActiveScene();
    48.                 //SceneManager.LoadScene ("Main Space Shooter Game.", LoadSceneMode.Additive);
    49.                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    50.  
    51.                 Debug.Log("Active scene is '" + Main + "'.");
    52.             }
    53.         }
    54.     }
    55.  
    56.  
    57.  
    58.                 if (GameOver) {
    59.                     RestartText.text = "Press R to play again.";
    60.                     //if (Input.GetKeyDown (KeyCode.R))
    61.                     Restart = true;
    62.                     break;
    63.                  
    64.                 }
    65.  
    66.             }
    67.  
    68.         }
    69.  
    70.     }
    71.  
    72.  
    73.  
    74.     // Added Score.
    75.     public void AddScore (int newScoreValue)
    76.     {
    77.         Score += newScoreValue;
    78.         UpdateScore ();
    79.     }
    80.  
    81.     // Updated Score.
    82.         void UpdateScore()
    83.         {
    84.         ScoreText.text = "Score:" + Score;
    85.  
    86.  
    87.         }
    88.  
    89.     // Game is Over.
    90.     public void TheGameisOver()
    91.  
    92.     {
    93.         GameOverText.text = "Game is Over";
    94.         GameOver = true;
    95.     }
    96.  
    97.  
    98. }
    void Update()
    {
    if(Restart)
    {
    if (Input.GetKeyDown (KeyCode.R))
    {???? }

    What is this ^^^^? I Mean key player press key (R) and played again. But what code?
     
    Last edited: Jul 12, 2017
  16. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    KeyCode.R is the "R" key (keycode) on the keyboard
    Input.GetKeyDown checks if a specific key on the keyboard is pressed(down)
    if (Input.GetKeyDown (KeyCode.R)) this says:
    "If the 'R' key on the keyboard is pressed(down), then do the programming code that follows in the braces"

    Code (csharp):
    1.  
    2. // If the 'R' key on the keyboard is pressed(down),
    3. //                            then do the programming code that follows in the braces
    4. if (Input.GetKeyDown (KeyCode.R))
    5. {
    6.    SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    7.    Debug.Log("Active scene is '" + Main + "'.");
    8. }
    9.  

    which in this case is to LoadScene and write a debug line to the log
     
  17. egurbas

    egurbas

    Joined:
    Jul 9, 2017
    Posts:
    2
    Dear, I have a problem about scrolling the background. The code is identical but when I make it play, I have the messages of

    instance: Background.
    instance: Background (1).
    "Failed creating system: 0x74a9860bcd26af7f725fc367ccad8cf7."

    in the Console screen. What might be the cause and how can I correct it? Thanks in advance.
     
  18. doubleg2002

    doubleg2002

    Joined:
    Jul 14, 2017
    Posts:
    1
    I need help with the converting to mobile part... for one, the scripts provided on the unity learn page where the video is located are not up to date, and I don't know how to fix them. secondly, I am a newbie to Unity, and I don't have any experience with C#. I have done some programing in JavaScript though.

    Please update the scripts to the newest unity code.
     
  19. stumpy28

    stumpy28

    Joined:
    Jul 14, 2017
    Posts:
    1

    I'm sure this has already been solved, but I found this bit in the manual that worked for me. Essentially, you need to declare a Rigidbody first, and then call it later (and hopefully I am stating that properly, since I am still learning programming). Here's the code I ended up with:

    Code (CSharp):
    1. public class PlayerController : MonoBehaviour
    2. {
    3.  
    4.     public Rigidbody rb;
    5.     void Start()
    6.     {
    7.         rb = GetComponent<Rigidbody>();
    8.     }
    9.  
    10.     void FixedUpdate()
    11.     {
    12.         float moveHorizontal = Input.GetAxis("Horizontal");
    13.         float moveVertical = Input.GetAxis("Vertical");
    14.  
    15.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    16.         rb.velocity = movement;
    17.     }
    18. }
     
  20. angel_luis

    angel_luis

    Joined:
    Jun 26, 2016
    Posts:
    17
    Hi, when I create the GameObject VFx based on a Quad, it creates a Mesh Collider. If you have a Collider, you don't need a Rigidbody? Why Unity creates a Collider without a Rigidbody?

    PS: the Unity 5 tutorial revision it has a mistake (https://oc.unity3d.com/index.php/s/rna2inqWBBysn6l). Page 14.

    private Rigidbody;

    It's private Rigidbody rb;
     
  21. angel_luis

    angel_luis

    Joined:
    Jun 26, 2016
    Posts:
    17
    Other question, I don't know why we make the rotation over the Rigidboy (rb.rotation) and not over the GameObject Transform (when we tilt the player spaceship).
     
  22. angel_luis

    angel_luis

    Joined:
    Jun 26, 2016
    Posts:
    17
    It's that a bug?

    I'm trying to replace the boundary system based in player limits, by walls colliders on the scenario.

    I AddForce to the player and y put a wall into the game scene, the player collide. But if, I put the wall out of the space of the scenario, the player doesn't collide. Bit by bit perforate the wall...

    PS: I have the old boundary script into the Player script component.
     
  23. angel_luis

    angel_luis

    Joined:
    Jun 26, 2016
    Posts:
    17
    And other question...

    Why the tutorial uses angularVelocity instead transform.rotation?

    I suppose that the tutorial uses it by performance purposes... (transform.rotation must be inside FixedUpdate)
     
    Last edited: Jul 16, 2017
  24. egurbas

    egurbas

    Joined:
    Jul 9, 2017
    Posts:
    2
    Anybodyfor help?
     
  25. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    egurbas
    This is probably not a common error, that could be why all you hear is the sound of people scratching their heads.

    I searched Google with the phrase: unity3d "Failed creating system:"
    And one of the responses was:
    "Ran into the same issue. If you clear your GI Cache via Edit->Preferences->GI Cache->Clean Cache , that fixes the errors/warnings and lets you bake".
    I'm not sure if this will help (since it seems to be related to a different issue), but...
    so, first try clearing the cache


    Second, comment out the code for the scrolling background, does your game compile, load, and play without any errors?
    Code (csharp):
    1.  
    2.     void Start () {
    3.         // *** startPosition = transform.position;
    4.     }
    5.    
    6.    // Update is called once per frame
    7.    void Update () {
    8.         // *** float newPosition = Mathf.Repeat(Time.time * scrollSpeed, tileSizeZ);
    9.         // *** transform.position = startPosition + Vector3.forward * newPosition;
    10.     }
    11.  
    or try unchecking the Background object
    upload_2017-7-16_15-30-27.png
    (it's checked, so its executable in this image)


    Third, Confirm that our C# script is NOT from the _Complete-Game/Scripts folder
     
  26. Seif

    Seif

    Joined:
    Aug 18, 2015
    Posts:
    9
    Hey guys :) i was wondering if there is a way to make another player play with me (multipakyer) from another device via bluetooth or internet .. anyone got an idea ??
     
  27. alexagosta

    alexagosta

    Joined:
    Jul 2, 2017
    Posts:
    2
    Hello,
    I have 2 issues with this tutorial

    1. At the very beginning I could not find the Web Player platform. I tried by WebGL but could not set properly the project setting resolution. I made the project for Windows platform and it seems to work fine. I only have to change the coordinates suggested in the examples.

    2 In lesson 15 the code

    Application.Loadlevel(Application.Loadedlevel)

    does not work.

    I've found the solution and substituted the code above with this

    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);

    or this

    int scene = SceneManager.GetActiveScene().buildIndex;
    SceneManager.LoadScene(scene, LoadSceneMode.Single);
    Time.timeScale = 1;

    Both work fine, but after that scenes reloads every object, player and hazards, appear dark as if the lightning are not working.

    Thank you for your support
     
  28. GhostRafa

    GhostRafa

    Joined:
    Jul 20, 2017
    Posts:
    2
    I am currently watching the tutorial and I have the first part of the PlayerController script written exactly as it is in the turtorial, but it still says all complier errors need to be fixed. What do I do?
     
  29. secondHandsome

    secondHandsome

    Joined:
    Jul 21, 2017
    Posts:
    1
    Hello,everyone.
    upload_2017-7-21_14-12-0.png
    upload_2017-7-21_14-20-23.png
    I want to build game on Android. But when I run It in My phone(HUAWEI P9 1920x1080),the player,enemy and asteroids will fly out of the screen. I try to change the resolution,but in the play setting,under the android tab,there is not resolution to set.The tutorial show I can change the resolution under the web tab. There is any way to make the game fit my phone?
     
    Seif likes this.
  30. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    When using the new Sceneanagement methods.
    Need to add the SceneManagement namaspace at the top of the script.

    Code (CSharp):
    1. UnityEngine.SceneManagement
    See how that goes
     
  31. alexagosta

    alexagosta

    Joined:
    Jul 2, 2017
    Posts:
    2
    Ok, I've solved the issue comparing my scene Lightning setting with the done scene ones
    There were some differences in positions, colors and mode (Realtime > mixed)
    Only I don't understand why I see the difference when I restart the game.
     
  32. madisonpie2

    madisonpie2

    Joined:
    Jan 6, 2017
    Posts:
    1
    [
    I'm having a strange issue where small orange dots will appear after an explosion on asteroids and disappear within a second or two. The length of the presence of the orange dot it definitely limited by the "lifetime" variable we created, but it's still there when the lifetime is shorter (which isn't ideal anyway because that affects the presence of the explosion VFZ prefab itself.
    Anyway, it's not that bad but I'd appreciate any advice!
    2017-07-24.png
     
  33. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    Is there a way to switch off specific sounds (asteroid explosion, laser bolt shots, etc) and music individually (via scripts) for the game in its current form, or will I have to change how the audio is currently setup?

    If I can change in current game form can you please help with the coding, or alternatively if not possible can you direct me to how it should now be setup for it to work in unity 5.
     
  34. tiwanaku322

    tiwanaku322

    Joined:
    Jul 26, 2017
    Posts:
    2
    I'm having the same problem as you. I can't currently see where I have gone wrong. I've peppered my script with Debug.Log and am debugging at the moment. I'll let you know if I solve this.
     
  35. tiwanaku322

    tiwanaku322

    Joined:
    Jul 26, 2017
    Posts:
    2
    Alright daveshan, so I solved the issue where the SimpleTouchPad doesn't translate into movement for the Space Ship.

    In my code I had :

    Code (CSharp):
    1.             Vector2 currentPosition = data.position;
    2.             Vector2 directionRaw = currentPosition - origin;
    3.             Vector2 direction = directionRaw.normalized;
    When really it has to be

    Code (CSharp):
    1.             Vector2 currentPosition = data.position;
    2.             Vector2 directionRaw = currentPosition - origin;
    3.             direction = directionRaw.normalized;
     
    Natez74 likes this.
  36. Seif

    Seif

    Joined:
    Aug 18, 2015
    Posts:
    9
    I have the same error here .. And I tried to search it for awhile but then gave up :(
     
  37. Seif

    Seif

    Joined:
    Aug 18, 2015
    Posts:
    9
    Is it only me or the touchpad control is so fast ?? I mean I just swipe and the player flies much faster than in the accelerometer ....and also was wondering is there any way to increase the sensitivity of the accelerometer ??
     
  38. Lorenzo_lo

    Lorenzo_lo

    Joined:
    Jul 24, 2017
    Posts:
    1
    a polygon of vehicle_playerShip is self-intersecting and has been discarded

    how can i fixed it?
     
  39. hectorgrey

    hectorgrey

    Joined:
    Oct 2, 2015
    Posts:
    1
    So, I'm getting this graphical bug quite early on in the tutorial (I have just added movement) - I have absolutely no idea what I might have done wrong or how to fix it, but I'm pretty sure that, where possible, I've done everything exactly as instructed in the videos thus far:

    screenshot.png

    I'm fairly certain that my settings for both the ship and the background are pretty much identical to the settings in the Done version, and the code is functionally identical (other than adding a reference to the rigid body so that I'm not calling GetComponent() all the time).

    Edit: Never mind - apparently I had the wrong camera setting - my Clear flag was set to "Don't Clear" instead of "Solid Color"...
     
    Last edited: Jul 28, 2017
  40. Simon1964

    Simon1964

    Joined:
    Jul 29, 2017
    Posts:
    12
    I've had trouble linking my script to the player controller in inspector. The inspector wasn't showing the public variables like shotspawn and firerate. I decided to delete the player script and go right back. Now I've sorted out the script I can't reload it onto the player in inspector because it says PlayerController already exists in that path. So I'm stuck. I can't go on and reload the script
     
  41. Simon1964

    Simon1964

    Joined:
    Jul 29, 2017
    Posts:
    12
    I'm getting this error when I get to introducing the tilt factor in lesson 5

    any ideas? I'm using the code exactly as in the lesson (which I see is using a Mac). I'm using win7 and visual studio.
     
  42. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    It's not a big deal. The line endings in Mac/*nix world are different (\0) than they are in PC/Win world (\cr\lf).
    VisStu is complaining but it is automagically fixing it.
    At some point VisStu will pop up a message box that asks if you want to change them (yes), or you can for force it:

    "The easiest way to change the line endings without having to modify anything in VS is to go to the File > Advanced Save Options. In the Advanced Save Options window, under Line endings drop down, select the line ending you want to use and click OK. Then save the script again; this will automatically change the line endings in your script when you save it. When you go back into Unity, the error will disappear."
    (Thanks to BrilliantOne, post #9 https://forum.unity3d.com/threads/inconsistent-line-endings.40671/)
     
    Simon1964 likes this.
  43. SpaceJesus04

    SpaceJesus04

    Joined:
    Jul 27, 2017
    Posts:
    1
    Hi, I'm having an issue with my GameController script and DestroyByContact script. I get this error:
    ype `GameController' does not contain a definition for `AddScore' and no extension method `AddScore' of type `GameController' could be found. Are you missing an assembly reference?

    Here is my code for both scripts:

    DestroyByContact
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class DestroyByContact : MonoBehaviour
    6. {
    7.     public GameObject explosion;
    8.     public GameObject playerExplosion;
    9.     public int scoreValue;
    10.     public GameController gameController;
    11.  
    12.     void Start()
    13.     {
    14.         GameObject gameControllerObject = GameObject.FindWithTag("GameController");
    15.  
    16.         if (gameControllerObject != null)
    17.             gameController = gameControllerObject.GetComponent <GameController>();
    18.  
    19.         if (gameController == null)
    20.             Debug.Log ("Cannot find 'GameController' script");
    21.     }
    22.  
    23.     void OnTriggerEnter(Collider other)
    24.     {
    25.         if (other.tag == "Boundary")
    26.             return;
    27.  
    28.         Instantiate(explosion, transform.position, transform.rotation);
    29.  
    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.  
    GameController
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class GameController : MonoBehaviour
    6. {
    7.     public GameObject hazard;
    8.     public Vector3 spawnValues;
    9.     public int hazardCount;
    10.     public float spawnWait;
    11.     public float startWait;
    12.     public float waveWait;
    13.     public GUIText scoreText;
    14.     public int score;
    15.  
    16.     void Start()
    17.     {
    18.         score = 0;
    19.         updateScore ();
    20.         StartCoroutine (spawnWaves ());
    21.     }
    22.  
    23.     IEnumerator spawnWaves()
    24.     {
    25.         yield return new WaitForSeconds (startWait);
    26.  
    27.         while(true)
    28.         {
    29.             for (int i = 0; i < hazardCount; i++)
    30.             {
    31.                 Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
    32.                 Quaternion spawnRotation = Quaternion.identity;
    33.                 Instantiate (hazard, spawnPosition, spawnRotation);
    34.                 yield return new WaitForSeconds (spawnWait);
    35.             }
    36.  
    37.             yield return new WaitForSeconds (waveWait);
    38.         }
    39.     }
    40.  
    41.     public void AddScore(int newScoreValue)
    42.     {
    43.         score += newScoreValue;
    44.         updateScore ();
    45.  
    46.     }
    47.  
    48.     void updateScore()
    49.     {
    50.         scoreText.text = "Score" + score;
    51.     }
    52. }
    53.  
     
  44. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144

    1. Please confirm there are no errors in console log upon execution. Specifically, confirm there is no line:
    Debug.Log ("Cannot find 'GameController' script");

    2. Confirm, in Unity, that the tag "GameController" is on the GameController game object
    upload_2017-7-29_23-20-22.png

    3. Change line 14 in DestroyByContact
    from: GameObject gameControllerObject = GameObject.FindWithTag("GameController");
    to: GameObject gameControllerObject = GameObject.FindGameObjectWithTag ("GameController");
     
  45. Simon1964

    Simon1964

    Joined:
    Jul 29, 2017
    Posts:
    12
    Thanks gwnguy. I've sorted it thanks but I there isn't a

    File > Advanced Save Options.

    in VS Community 2017 it seems. I'll try to muddle along from now and wait for that message box every time I save.
     
  46. PoulpX

    PoulpX

    Joined:
    Jul 27, 2017
    Posts:
    2
    Hello,

    I have been doing some modification to the tutorial for learning purpose. But I have an issue.
    I have modified the prefab of the enemy ship, I wanted to change the mover.cs, so I created another script that allow a different way to handle speed for the enemy ship. Since then the enemy ship don't want to move down.
    I have put back the original script (even try to use the one from the Done folder) but I still have the issue. The asteroids are moving nicely, but not the enemy ship.
    Even stranger if I drag from the prefab a enemy ship it's moving nicely. And I have logged the action in the script and everything looks fine. Do you have any idea?

    Thanks
     
  47. Simon1964

    Simon1964

    Joined:
    Jul 29, 2017
    Posts:
    12
     
  48. Simon1964

    Simon1964

    Joined:
    Jul 29, 2017
    Posts:
    12
  49. Simon1964

    Simon1964

    Joined:
    Jul 29, 2017
    Posts:
    12
    I'm at part 9: Creating Hazards. I've loaded the Script for Unity 5.1 so here is the script:

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

    public class RandomRotator : MonoBehaviour
    {
    public float tumble;
    private Rigidbody rb;

    void Start ()
    {
    rb = GetComponent<Rigidbody>();
    rb.angularVelocity = Random.insideUnitSphere * tumble;
    }
    }


    The trouble I'm having is that when I back to Unity the tumble variable isn't appearing in Random Rotator script box at the bottom of the Astroid Inspector. I can't see anything different from what the tutorial shows except updating with using rb for Rigidbody as the upgrade guide recommends.
     
  50. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    log out of your unity session, then log back in ... yea, I know....

    confirm there are no build or execution errors in the console log

    and your prefab asteroid is in your hierarchy, (NOT in "_Completed_Game" and looks like:
    upload_2017-7-30_11-27-58.png