Search Unity

Space Shooter Tutorial Q&A

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

  1. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    victore82, line 7 is all messed up.

    Don't write function. You are creating a function (or method as C# likes to call it) and it will return void. You aso have collider and other reversed. line 7 should be

    void OnTriggerExit (Collider other)

    Here is the code as I have it written (keep your class name the same as it is)

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class boundary : MonoBehaviour
    5. {
    6.     void OnTriggerExit(Collider other)
    7.     {
    8.         Destroy(other.gameObject);
    9.     }
    10. }
     
  2. reyloko55

    reyloko55

    Joined:
    Nov 15, 2016
    Posts:
    3
    Hello, i have a little problem with my game, When I press the "R" key in my game, the scene starts again but without lighting.

    here is a screemshot before and after press R in my Game...

    upload_2017-1-19_22-13-5.png

    upload_2017-1-19_22-14-4.png
     
  3. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    reyloko55,

    not sure if you solved you issue yet or not, but while I was looking through for a solution to a problem I am have I noticed in post #1985 that oboshape mention turning off automatic baking in the lighting settings. Perhaps try that.
     
  4. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    So I am having a difficulty and a question.

    I notice when I play the game in the editor everything works great, but every time I shoot an asteroid the console displays an error that says "Destroying assets is not permitted to avoid data loss. If you really want to remove an asset use DestroyImmediate(theObject, true);. So I changed my scripts to that and then the game doesn't destroy anything but tells me to use Destroy.GameObject ( paraphrase. didn't write exact verbiage down). So I changed it back to the original and it works again but still gives me the error.

    So, does anyone else get that error, and what does it mean?

    Secondly when I build the game (PC Standalone) the game will destroy the first asteroid hit, but then after that the bolts just pass through as though no collision occurs. If I collide the ship with the asteroid I get the FX's and explosion sounds and Game Over notice, but neither ship nor asteroid is destroyed. Resetting the level with R starts the level over, but the issues remain.

    Questions:
    What might be causing this, since it works perfect in the editor?
    What happens when a game is built that might give me an idea where to start troubleshooting?
    How to do I access a debug log on a game that is already built?

    Thanks in advance.
     
  5. LeRougePanda

    LeRougePanda

    Joined:
    Jan 20, 2017
    Posts:
    4
    I'm having an issue during the GameController tutorial while trying to set the Random.Range x values I copied the exact code and it does not spawn the asteroid randomly on the X axis. only at the X origin (right in front of the ship) no matter how many times I stop and restart play mode, it's never in a different location.

    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. }
     
  6. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    I'm not seeing anything wrong with the code.

    Two things I can think of is 1) did you set your spawnValues in the inspector? or 2) (not as likely as one) check the origin of your asteroid object and make sure that it is correct and not moving towards and away from the camera.
     
  7. Tritize

    Tritize

    Joined:
    Jan 18, 2017
    Posts:
    8
    Hi, new problem for me!

    I finished the tutorial and I need to build the project. So I build it using webgl.
    I click on build, then I have to select a file where I want to save the game (seems like I can't name it?).

    So then I click on save, the building start.. And after it's done, the files where I wanna save it open.
    But it's empty! There is nothing! Nothing at all.
    I've tried severa times, changing the destination folder, trying to hit build and run... Nothing.
    My gamework fine in Unity and I don't have any errors in the console.
    So if someone plz know how I can build the game in webgl (as there is no longer webplayer option?????).

    Thanks







    I think it's not "function OnTriggerExit (other : Collider)"
    but "void OnTriggerExit(Collider other)"
     
  8. Mutation

    Mutation

    Joined:
    Oct 9, 2014
    Posts:
    9
    I have just finished completing the tutorial, unfortunately I am not a coder and trying to learn. Could someone advise on how to incorporate Power Ups and Shield elements for player ship.

    Also how to complete one wave and display Wave 1, triggering Wave 2 to increase in speed attacks from enemy and so on?

    Any help is greatly appreciated

    M
     
  9. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    Figured out my issue why my build wasn't working.

    I jumped ahead of the tutorial and it bit me in the backside. I noticed the explosions building up in the hierarchy after doing the destroy by contact lesson, so I added my own line to destroy them. It wasn't until a couple lessons later that issued was addressed and the instructor said doing it that way wouldn't work so he used destroy by time.

    As soon as I removed my destroy by contact line and just used destroy by time everything works now.

    He never does explain why it doesn't work though. It would be nice if he would explain that part.
     
  10. renau

    renau

    Joined:
    Jan 22, 2017
    Posts:
    1

    Hi, i had the same error when doing scrolling shooter tutorial. I add a " using UnityEngine.SceneManagement;" at the top of the GameController script and error disappear

    I hope it can help you (sorry for my english)
     
  11. LeRougePanda

    LeRougePanda

    Joined:
    Jan 20, 2017
    Posts:
    4
    The issue was actually resolved swiftly after posting this, I didn't have the spawn value X set to 6.

    But now I am having a different issue entirely where my fonts are not displaying at all for the Score text.
    In the updated manual provided with the tutorial, it says to

    • Update the GUIText.text with “Score Text”.
    - This will make the GUIText object easier to see on screen.

    But I am unaware of a GUIText.text option or variable. I am assuming that is where I am having the issue.
    This whole tutorial has been confusing to a degree since it's in an older version of unity.
     
  12. LeRougePanda

    LeRougePanda

    Joined:
    Jan 20, 2017
    Posts:
    4
    Apparently, it was the Y transform set higher than 0.5 but I set that to 0.5 immediately after creating the GameObject. *Sigh* I'm not sure what's happening anymore with my brain apparently.
     
  13. LeRougePanda

    LeRougePanda

    Joined:
    Jan 20, 2017
    Posts:
    4
    Guys, I'm sorry for all these very newbie questions, I'm literally just starting fresh with Unity and coding in general, I would honestly like to find legit classes somewhere to learn all this but the lack of proper finances is a big problem so I'm doing what I can.

    There is another issue I am running into with Microsoft Visual Studio and that is when I go to type for example

    "void Update" it always, ALWAYS autocorrects to "private void Update" I'm wishing to disable this auto-completing entirely when I hit the spacebar. I tried finding the solution elsewhere but all I found was something I could not find in MVS which is a checkbox for IntelliSense stating "Committed by pressing the space bar". There is another similar issue I can't resolve and that's when I type ";" to end a line of code it deletes spaces between words and sets of parenthesis.

    Maybe these things are not important, but for simplicities sake of following the tutorial, I want it to stop. but if this is something that changed in the newer version of Unity or MVS and the difference is null then I will just put up with it knowing it's okay and move forward.
     
  14. Deleted User

    Deleted User

    Guest

    Legit classes? You have everything you need here to learn how to use Unity: https://unity3d.com/learn

    All you need is not money, it's work, work and work. ;)
     
  15. sudeshna1509

    sudeshna1509

    Joined:
    Jan 25, 2017
    Posts:
    21
    I am facing problem in creating the boundary to prevent accumulation of bolt clones. Copied the code but still the clones are not getting destroyed.Please help!!
     
  16. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    sudeshna1509, your going to need to give us a little more to go on. At a minimum if you could post your Boundary script we could look at it for errors.
     
  17. ravan333

    ravan333

    Joined:
    Jan 25, 2017
    Posts:
    1
    Hi
    I have just installed personal version of unity 5.5.1, in the asset store when i am trying to download the space shooter free assets, a new apache license window opens. please help in downloading those assets.
     

    Attached Files:

    Last edited: Jan 26, 2017
  18. Mutation

    Mutation

    Joined:
    Oct 9, 2014
    Posts:
    9
    Hi guys I have completed the whole course and noticed that when the player is static and the asteroid or ship collide with the player ship the player is awarded 10 or 20 points respectfully. How do I resolve this?
     
  19. Straesso

    Straesso

    Joined:
    Jan 28, 2017
    Posts:
    2
    I have a problem with the presentation of the GUIText Objects ScoreText and RestartText. In Unity Game-Window, both texts are displayed withing the gaming area on the upper left and right.

    When i create a WebGL or Windows Stand-Allone-Build, both texts are displayed in the left and right edges of the screen - outside the gaming area.

    What can i do?

    2017-01-28 09_54_40-SpaceShooter.png
     
  20. ladiesandgonts

    ladiesandgonts

    Joined:
    Jan 31, 2017
    Posts:
    2
    My script has no errors but the score only goes up once then stops at 10. I did use += before you say xd :).
     
  21. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    Please show your GameController script and your DestroyByContact script. Not enough info to go on otherwise.
     
  22. solrac156

    solrac156

    Joined:
    Feb 2, 2017
    Posts:
    1
    Hi! I'm starting with this project (I'm very new to Unity) and when I go to the Build Settings I can't find Web Player as a platform. Can someone tell me how can I get this platform, so I can develop for ir? Thanks!
     
  23. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    It is now the WebGL player. You will probably need to download the module, but the option should be there.
     
  24. TerryThai

    TerryThai

    Joined:
    Feb 2, 2017
    Posts:
    1
    Please help me for this error, I got it when trying to fire

    MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    PlayerController.Update () (at Assets/Scripts/PlayerController.js:25)

    and this is my code:

    Code (JavaScript):
    1. #pragma strict
    2.  
    3. class Boundary
    4. {
    5.     var xMin:float;
    6.     var xMax:float;
    7.     var zMin:float;
    8.     var zMax:float;
    9. }
    10.  
    11. var speed : float;
    12. var tilt:float;
    13. var boundary : Boundary;
    14.  
    15. var shot:GameObject;
    16. var shotSpawn:Transform;
    17. var fireRate:float;
    18.  
    19. private var nextFire:float;
    20.  
    21. function Update(){
    22.     if (Input.GetButton("Fire1") && Time.time > nextFire)
    23.     {
    24.         nextFire = Time.time + fireRate;
    25.         Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
    26.     }
    27. }
    28.  
    29. function FixedUpdate(){
    30.     var moveHorizontal : float = Input.GetAxis("Horizontal");
    31.     var moveVertical : float = Input.GetAxis("Vertical");
    32.  
    33.     var rb:Rigidbody = GetComponent.<Rigidbody>();
    34.  
    35.     var movement : Vector3 = new Vector3(moveHorizontal,0.0f,moveVertical);
    36.  
    37.     rb.velocity = movement*speed;
    38.  
    39.     rb.position = new Vector3
    40.         (
    41.             Mathf.Clamp(rb.position.x,boundary.xMin,boundary.xMax),
    42.             0.0f,
    43.             Mathf.Clamp(rb.position.z,boundary.zMin,boundary.zMax)
    44.         );
    45.      rb.rotation=Quaternion.Euler(0.0f,0.0f,rb.velocity.x*-tilt);
    46. }
    Many thanks
     
  25. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    I don't know Java Script, but when I read the error it somewhat points to where you can start debugging.

    It says the error is in Line 25, and it looks as though you are trying to instantiate an object which has been destroyed, The actual cause of the error may be in your Destroy by Boundary, or Destroy by Contact scripts, or possibly in the hierarchy.

    Do you get at least one shot fired before you get the error? Maybe you are somehow destroying your prefab and not just an instantiation of the prefab.

    Sorry I'm not much help on this, but hopefully gives you an idea where to start looking.
     
  26. JulianWebb

    JulianWebb

    Joined:
    Jan 27, 2017
    Posts:
    1
    Hi everyone! In the "Ending the Game" section of the tutorial it says to use
    Code (csharp):
    1.  
    2. Application.LoadLevel(Application.LoadedLevel);
    3.  
    In order to restart the level but Unity is telling me it's outdated and I should use
    Code (csharp):
    1.  
    2. SceneManager.LoadScene("Main")
    3.  
    I wonder if the tutorial could be updated to reflect that and go into a bit more detail on it?
     
  27. DryishRain

    DryishRain

    Joined:
    Feb 3, 2017
    Posts:
    1
    Hi everyone,

    Probably a dumb moment on my part. When trying to follow the tutorial I couldn't complete the first step, as "Web Player isn't an available build platform. I tried doing it in Web GL but the build freezes at "Converting to C++" or something like that.

    What am I doing wrong?
     
  28. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    drunkenwailer,

    The WebGL build does hang at the C++ conversion for a long time, upwards of 4 or 5 minutes on my old computer. Try letting run for awhile to make sure you are just not canceling to soon.
     
  29. Deleted User

    Deleted User

    Guest

    Use the code tags when you post a script: http://forum.unity3d.com/threads/using-code-tags-properly.143875/
     
  30. Alexei_UA

    Alexei_UA

    Joined:
    Dec 26, 2016
    Posts:
    6
    How can I delete black borders at sides of main camera?
    When I build the game to android it looks the same at my phone.
     
    Last edited: Feb 6, 2017
  31. zkeyblade

    zkeyblade

    Joined:
    Feb 7, 2017
    Posts:
    1
    Hello, I have a question about the script execution order.
    In "Enemy Ship" prefab, why the Start () in Mover.cs always called earlier than the Start () in EvasiveManeuver.cs? I have debugged for this several times.I'm also read the doc(https://docs.unity3d.com/Manual/ExecutionOrder.html) but I didn't get the answer.
     
  32. alexjr1194

    alexjr1194

    Joined:
    Feb 3, 2017
    Posts:
    4
    hello im on the shooting the shots part of the tutorial and I've type up the code for it but I can't get my character to shoot the shots. the Input.GetButton script is different on the video then it is on the manual here is my script so far can any help me fix it so I can make my character shoot

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [System.Serializable]
    6. public class Boundary
    7. {
    8. public float xMin, xMax, zMin, zMax;
    9. }
    10.  
    11. public class PlayerController : MonoBehaviour
    12. {
    13. private Rigidbody rb;
    14.  
    15. void Start ()
    16. {
    17. rb = GetComponent<Rigidbody>();
    18. }
    19.  
    20. public float speed;
    21. public float tilt;
    22. public Boundary boundary;
    23. public float fireRate;
    24. public float fireDelta = 0.5f;
    25.  
    26. public GameObject Bolt;
    27. public Transform ShotSpawn;
    28.  
    29. private float nextFire = 0.5f;
    30. private float myTime = 0.0f;
    31.  
    32. void Update ()
    33. {
    34.  
    35. myTime = myTime + Time.deltaTime;
    36.  
    37. if (Input.GetButton("Fire1") && myTime > nextFire)
    38. {
    39. nextFire = myTime + fireDelta;
    40. //newProjectile=
    41. Instantiate(Bolt, ShotSpawn.position, ShotSpawn.rotation); //asGameObject;
    42.  
    43. //createcodeherethatanimatesthenewProjectile
    44.  
    45. nextFire = nextFire - myTime;
    46. myTime = 0.0F;
    47. }
    48. }
    49.  
    50. void FixedUpdate ()
    51. {
    52. float moveHorizontal = Input.GetAxis ("Horizontal");
    53. float moveVertical = Input.GetAxis ("Vertical");
    54.  
    55. Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    56. rb.velocity = movement * speed;
    57.  
    58. rb.position = new Vector3
    59. (
    60. Mathf.Clamp (rb.position.x, boundary.xMin, boundary.xMax),
    61. 0.0f,
    62. Mathf.Clamp (rb.position.z, boundary.zMin, boundary.zMax)
    63. );
    64.  
    65. rb.rotation = Quaternion.Euler (0.0f, 0.0f, rb.velocity.x * -tilt);
    66. }
    67. }
     
  33. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    alexjr1194,

    First of all, if you want to make scripting life easier for yourself, use proper indenting. It makes the code much easier to read. Also I see you have a bunch of variables declared after your start() method. While it will still work as far as I know, I like to group my field variables before the start() method and sort by access scope. But onto your issue.

    I see a variable in your script that I don't have in my functioning script, mainly fireDelta. I know sometimes in the videos the instructor will do something one way then show another different or better way, and I think you have some of the deleted variables still in your script.

    Here is my completed script. compare it to yours and see if you can find the differences.

    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.     public Boundary boundary;
    13.     public GameObject shot;
    14.     public Transform shotSpawn;
    15.  
    16.     public float speed;
    17.     public float tilt;
    18.     public float fireRate;
    19.  
    20.     private Rigidbody rb;
    21.     private AudioSource audioSource;
    22.     private float nextFire;
    23.  
    24.     void Start()
    25.     {
    26.         rb = GetComponent<Rigidbody>();
    27.         audioSource = GetComponent<AudioSource>();
    28.     }
    29.  
    30.     void Update()
    31.     {
    32.         if (Input.GetButton("Fire1") && Time.time > nextFire)
    33.         {
    34.             Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
    35.             audioSource.Play();
    36.             nextFire = Time.time + fireRate;
    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, boundary.xMin, boundary.xMax),
    52.             0.0f,
    53.             Mathf.Clamp(rb.position.z, boundary.zMin, boundary.zMax)
    54.         );
    55.  
    56.         rb.rotation = Quaternion.Euler(0.0f, 0.0f, rb.velocity.x * -tilt);
    57.  
    58.     }  
    59. }
     
  34. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    That is a good question zkeyblade. I looked through the manual and didn't see it answered there. Perhaps post this in the general editor forum and you will have a much better chance of an answer.
     
  35. cwardin

    cwardin

    Joined:
    Feb 8, 2017
    Posts:
    2
    I've got everything working in webGL, but I'm not having luck with player movement when porting to the table. I've got the movement script wired to the "Movement Zone" Game object and I've got a debug statement in the OnPointerDown handler and it never seems to be called. I've turned off the game controller and the player controller script (note with player controller script on, when I touch the table, the ship fires as expected). The docs say the touch handler is now automatically within the standard input module so I didn't add that as a component (I think that's OK).

    I think I must be missing something pretty simple, but I can't see it as yet. Screenshot showing the script connected and the code are both below. If anything at all works in this I should see "touched" in the console when I touch the area where the image is (lower left as in the tutorial), but it never shows up.

    upload_2017-2-8_11-27-49.png


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

    cwardin

    Joined:
    Feb 8, 2017
    Posts:
    2
    I found it, it was simple... I needed to check "Raycast Target". Once I did that it worked as expected.
     
  37. Scivreds

    Scivreds

    Joined:
    Feb 7, 2017
    Posts:
    2
    hello everyone

    This is my first post onto a forum so I hope all goes well.
    First off, I am very new to programming but the concepts seem easy to follow.
    But I am having a bit of trouble with the shooting tutorial.

    here are my stats and my problems
    I'm using Unity 5.5 and i am trying to reconcile all the different code i've seen.

    so far, out of the 5 times i've watched and rewritten the code from
    scratch, Ryeath's Dec 4, 2016 post has had the most success but still fires an endless stream of shots.

    I used the Done_PlayerController, and it seems just as outdated as the video.

    in the video it shows him cutting straight from the reference page and i tried
    that as well but had so many issues with the "Time" aspects of the script and nothing firing.

    before finding Ryeath's post, the best i could get was either firing only one shot
    or firing the shots with the accumulating (clone) labels. that seemed a simple fix but it
    put me back to firing only one shot when i hit ctrl.

    i spent all night trying to fix the issue with no luck (and definitely no skill, lol).

    If the issues is just something small i overlooked then i can direct my frustrations
    back at myself and deserve the missing hairs i pulled out. but i think the space
    shooter upgrade manual needs some pointers between 9:20 and 10:20 because that
    is where my project stops working.

    I am currently using Ryeath's script for the PlayerController as it works the best so far. Thank You Ryeath!

    ask any questions about my setup if you need to because i'm not sure what to offer, but i need help.
     
  38. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    Scivreds,

    If I understand you the game is shooting shots ok, but building up a large collection of shot clones? Don't worry too much about that as it will be addressed in a later video. I did the same thing, worrying about the build up of clones, and came up with my own solution that ended up causing me a bunch of problems later. So for now just let them build up.
     
    Scivreds likes this.
  39. Scivreds

    Scivreds

    Joined:
    Feb 7, 2017
    Posts:
    2
    Thank you so much!

    i was for sure that it was something i did wrong. now i can continue my unity3d journey
     
  40. mikebrsv

    mikebrsv

    Joined:
    Feb 11, 2017
    Posts:
    1
    Couldn't find the Done folder in the assets package. Has it been taken down?
     
  41. LindieDB

    LindieDB

    Joined:
    Apr 11, 2015
    Posts:
    1
    Need some help. I am on the extending part of the tutorial, and have just implemented my enemy ship's bolts. Problem: the enemy ship game object destroys itself upon first fire, but the enemy weapon sound keeps playing even with no enemy or shots being fired. Audio is not set to loop.

    Is my error in WeaponsController?

    Code (CSharp):
    1. public class WeaponsController : MonoBehaviour {
    2.  
    3.     public GameObject shot;
    4.     public Transform shotSpawn;
    5.     public float fireRate;
    6.     public float delay;
    7.  
    8.     private AudioSource audioSource;
    9.  
    10.     void Start () {
    11.         audioSource = GetComponent<AudioSource>();
    12.         InvokeRepeating("Fire", delay, fireRate);
    13.     }
    14.     void Fire()
    15.     {
    16.         Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
    17.         audioSource.Play();
    18.     }
    19. }
    or in DestroyByContact?

    Code (CSharp):
    1.     void OnTriggerEnter(Collider other)
    2.     {
    3.         if (other.CompareTag ("Boundary") || other.CompareTag ("Enemy"))
    4.         {
    5.             return;
    6.         }
    7.  
    8.         if (explosion != null)
    9.         {
    10.             Instantiate(explosion, transform.position, transform.rotation);
    11.         }
    12.  
    13.         if (other.CompareTag ("Player"))
    14.         {
    15.             Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
    16.             gameController.GameOver();
    17.         }
    18.  
    19.         gameController.AddScore(scoreValue);
    20.         Destroy(other.gameObject);
    21.         Destroy(gameObject);
    22.     }
     
  42. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    LindieDB,

    first thing I would check is if you remembered to tag your enemy ship as Enemy in the inspector.
     
  43. Spider_Brv

    Spider_Brv

    Joined:
    Feb 2, 2017
    Posts:
    1
    Hi, i'm new here and with game development, but I think you need to use a "void" instead "function

    Code (CSharp):
    1. void OnTriggerExit(Collider other)
    2.     {
    3.         // Destroy everything that leaves the trigger
    4.         Destroy(other.gameObject);
    5.     }
     
  44. jrsolar

    jrsolar

    Joined:
    Feb 15, 2017
    Posts:
    1
    Thanks I had the same problem!!!
     
  45. difficultnerd

    difficultnerd

    Joined:
    May 3, 2014
    Posts:
    52
    I was having issues with getting the bolts move when you drag the prefab into the hierarchy (video 06, creating shots, about 13 minutes in) - turns out that my mover script had a minor error in it:

    void start () {
    }
    is different to

    void Start () {
    }​
     
  46. Pmpn8ez

    Pmpn8ez

    Joined:
    Feb 17, 2017
    Posts:
    1
    Just finished the basic tutorial. Loved it. Wierd thing happened after the score lesson. Going to play with it some more but after adding the finishing touches on the game it started running slower than normal/in the video. Anyone experienced this? I googled some things and tried turning vsync off, I tried playing at "faster" settings but still the game seems slow. not laggy just slower than in the earlier stages of making the scene. Built pc game is as slow as in the editor as well. I played the android version from the app store and its much quicker.
     
  47. stanzy

    stanzy

    Joined:
    Dec 12, 2016
    Posts:
    17
  48. Jose_limo

    Jose_limo

    Joined:
    Feb 19, 2017
    Posts:
    1
    Hi, I have problems with the script. The Space Controller script have some changes from Unity 5 and above. I saw the upgrade guide but I don´t full understand. This is the script

    using UnityEngine;


    [System.Serializable]

    public class Boundary

    {

    public float xMin, xMax, zMin, zMax;

    }


    public class PlayerController : MonoBehaviour

    {

    private Rigidbody rb;

    public float speed;

    public float tilt;

    public Boundary boundary;




    void Update ()

    {

    float moveHorizontal = Input.GetAxis("Horizontal");

    float moveVertical = Input.GetAxis("Vertical");


    Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

    rb.velocity = movement * speed;


    rb.position = new Vector3

    (

    Mathf.Clamp(rb.position.x, boundary.xMin, boundary.xMax),

    0.0f,

    Mathf.Clamp(rb.position.z, boundary.zMin, boundary.zMax)

    );


    rb.rotation = Quaternion.Euler(0.0f, 0.0f, rb.velocity.x * -tilt);

    }

    }


    The console panel show the next message:

    l The referenced script on this Behaviour is missing!

    l The referenced script on this Behaviour (Game Object ‘Player’)is missing!


    I working in Windows with Unity 5.5.1f1 Personal Version.

    I just don’t know where is the error!!
     
  49. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    Hello, could someone help me? I want that hazards were moving with different speed. In this case they sometime overlap one another, what is not a good thing. I would like that hazards avoid another hazards. What the way would you suggest to solve this problem? Thanks
     
    Last edited: Mar 4, 2017
  50. Ryeath

    Ryeath

    Joined:
    Dec 4, 2016
    Posts:
    265
    Jose_limo,

    The code looks okay, though it would be easier to read if you had used code tags. I would start by making sure you have assigned your player object to the controller script by dragging it from the hierarchy over to the slot in the script inspector.