Search Unity

Space Shooter Tutorial Q&A

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

  1. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You don't, actually. This is perceived. The point where the move is calculated from is where you set your finger down. If you've moved significantly far away from the start point, you need to move your finger back to that Center / Start point. Just like centering a joystick. You can short cut this by lifting your finger and starting a new touch and new start point.
     
  2. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Can you please learn to format your code.
    http://forum.unity3d.com/threads/using-code-tags-properly.143875/
     
  3. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Don't forget that unity's "JavaScript" is not really "JavaScript".

    The C# code and the JS code should be primarily identical. I would double check the construction of the prefab, rather than test the code.
     
  4. scott_mcc

    scott_mcc

    Joined:
    May 11, 2015
    Posts:
    5
    Hey guys I ve been going over these tutorials for the past week and I am having a bit of a strange bug where the player object seems to de-spawn when I try and test the game in the play mode. I have no idea why this is happening there is nothing in the console to help me either. I have a screen shot of the object in the scene view but as I say in game view it disappears from the hierarchy cant move or shot lasers it doesn't even interact with the asteroids any ideas ? If you need any info let me know
     
  5. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Is it being destroyed in the first frame?

    You can create a new script that tests for this with code like this:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class TestForDestruction : MonoBehaviour {
    5.  
    6.     void OnDestroy ()
    7.     {
    8.         Debug.Log ("This item: " + gameObject.name + " was Destroyed.");
    9.     }
    10.  
    11.     void OnTriggerEnter (Collider other)
    12.     {
    13.         Debug.Log ("Trigger contact with: " other.gameObject.name + "!");
    14.     }
    15. }
     
  6. sbk2015

    sbk2015

    Joined:
    May 13, 2015
    Posts:
    1
    I have no problem in tutorial 05,but I still don't get it about the tilt part.
    I want to tilt in horizontal way,so I should write
    Quaternion.Euler(new Vector3(rb.velocity.x*-tilt,0.0f,0.0f));
    however rb.velocity.x*-tilt should be put in the third(z) part to make it works.Why?
     
  7. scott_mcc

    scott_mcc

    Joined:
    May 11, 2015
    Posts:
    5
    Thanks for the code it appears the player is being destroyed by the boundary as soon as it spawns I have no idea why though any suggestions ?
     
  8. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    morning @sbk2015.

    the Z axis in this game, is the one that goes forward from the player (ie up the screen).
    so if you imagine a skewer being placed through the player along the z axis. rotating that skewer or Z axis, would give the desired bank effect.
    putting the skewer in the X axis and rotating, would look like the ships nose is pointing up and down.

    try it and see with it in the X axis, so you get an idea what happens if you put the tilt in a different one :)

    ive just done a little doodle to try and explain.
     

    Attached Files:

    sbk2015 likes this.
  9. Zamas

    Zamas

    Joined:
    Apr 15, 2015
    Posts:
    35
    Is your boundary isTrigger. If not, and if your player isn't, then the boundary will push the player gameobject outside of itself, which would activate the OnTriggerExit action.
     
  10. scott_mcc

    scott_mcc

    Joined:
    May 11, 2015
    Posts:
    5
    Thanks for the suggestion I checked and the Boundary is trigger and the player isn't I tried mixing these options around but it dosnt seem to be helping too much; In fact when I stopped the boundary being a trigger the ship arrived but it was floating at the corners flashing in and out of existence. Is it perhaps something to do with the position of the ship or the boundary for the ship ?
     
  11. Zamas

    Zamas

    Joined:
    Apr 15, 2015
    Posts:
    35
    Just to be sure but your classe is OnTriggerExit and not OnTriggerEnter right ?

    Another thing to do is to change your ship layer and add a layer check to the triggerexit classe before destorying. You can also do that with a tag but I don't which one would be better.
     
  12. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Nice doodle!
     
  13. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You will need to go back thru that episode and check the code on the player and the boundary.

    If these are not set correctly, yes, the boundary could destroy the player.
     
  14. o0_JdogJ_0o

    o0_JdogJ_0o

    Joined:
    May 16, 2015
    Posts:
    1
    hey im following the space shooter guide and am at the point when you add movement to the ship i followed the code exactly but it keeps saying there is a error on my code when its exactly the same as the tutorial it seems to not like the rigidbody.velocity = movement section. any help?

    void FixedUpdate ()
    {

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

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

    }

    }


    *Edit. i actually found out that instead of Rigidbody.velocity it needs to be GetComponent<Rigidbody> ().velocity. hopefully yhis edit also helps any others with this problem
     
    Last edited: May 16, 2015
    Kuyamazing likes this.
  15. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Please learn to format your code using code tags.
     
  16. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Glad you got it working. Yay!

    Also, check the original post for any upgrade notes.
     
  17. GrayDwarf

    GrayDwarf

    Joined:
    May 6, 2015
    Posts:
    9
    Hi, I'm new to Unity and made my way through the space-shooter tutorial and am now using the Done_ files to work through the conversion to mobile tutorial. I've gotten hung up on getting the touch areas to work correctly. I can use the mouse left/right click buttons on the touch areas in the editor just fine. When I test on Remote 4, I get inconsistent behavior. Scenarios:
    • If my first touch is on the movement area, pointerID is -1 and the ship flys around fine. When I place a second finger on the fire area, OnDrag in movement ends up getting "-1" for pointerId so the movement script thinks I've dragged to far right.
    • If I place a first finger on fire, the ship fires as expected. If I place a second finger on the movement area, nothing happens.
    • If I place a first finger on fire and drag it to the movement area and then place a second finger down in the movement area, I can fly and shoot as expected. *Edit* - Well, almost as expected. I can't move the fire finger or the movement script picks it up as a move which makes my head spin just a little bit.
    • So it seems like pointerId isn't working as expected. I've got a Note 2 if that matters. Android Version 4.4.2.
     
    Last edited: May 18, 2015
  18. OwiHH

    OwiHH

    Joined:
    May 18, 2015
    Posts:
    2
  19. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    There seems to be an issue with the unity remote and the UI toolset. Build to the device and check that everything is working as expected.
     
  20. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
  21. Bodega

    Bodega

    Joined:
    May 20, 2015
    Posts:
    1
    Thank you! After much searching this was the tiny detail I missed. I could see my bolts in the regular view after firing but not the game view. I guess because they were pointed down so you couldn't see them from the top. I thought they were just billboarding. I'm glad I came across this comment.
     
  22. PowerZ

    PowerZ

    Joined:
    May 20, 2015
    Posts:
    2
    Hi there, I was moving along swimmingly when I got an error I can't seem to figure.
    It's error CS1547 at line 36,24 keyword void cannot be used in this context. It's weird because I didn't touch that line during this lesson which is lesson 8 shooting shots. It seems to be referencing the void FixedUpdate (). If someone could take a look at my coding and see if I'm wrong and perhaps suggest a fix I would be super appreciative. Sad noobish gripping aside, I love these tutorials, and this engine. Kudos to all and my thanks. Hope this wasn't too long or rambling.

    edit- nvm I was being stupid. Figured it out. Missing Syntax probably spacing out lol
     

    Attached Files:

    Last edited: May 21, 2015
  23. Allie_98

    Allie_98

    Joined:
    May 21, 2015
    Posts:
    15
    Okay I have gone through this ENTIRE thread and none of this has helped me.
    this is my code;
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class PlayerController : MonoBehaviour
    6. {
    7.  
    8.     void FixedUpdate()
    9.     {
    10.         float moveHorizontal = Input.GetAxis("Horizontal");
    11.         float moveVertical = Input.GetAxis("Vertical");
    12.  
    13.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical)
    14.         rigidbody.velocity = movement;
    15.     }
    16. }
    17.  
    This is the error i'm getting;

    Please help me. I've been going through pages and pages of Q&A's and nothing is helping my problem.
     
  24. PowerZ

    PowerZ

    Joined:
    May 20, 2015
    Posts:
    2
    Quote:
    Unity 5: Common components are no longer cached and there are no "helper references" anymore.
    • Automatic references to attached components no longer exist in Unity 5.
    • These include attached components such as the Rigidbody, Collider and Light which in previous versions of Unity could be accessed by the shorthand rigidbody, collider and light references.
    • The recommended solution to this is to create a variable to hold the reference, populate the reference in Start(), and use the reference variable to access this reference.
    • Code (csharp):

    Code (csharp):
    1. private Rigidbody rb;
    2.  
    3. void Start ()
    4. {
    5.    rb = GetComponent<Rigidbody>();
    6. }
    7.  
    8. void Update ()
    9. {
    10.    if (Input.GetButton("Fire1"))
    11.    {
    12.       rb.velocity = Random.InsideUnitSphere
    13.    }
    14. }
    • Be aware that simply replacing the obsolete rigidbody reference with GetComponent<Rigidbody>(); will work, but is inefficient, as the code will look up this reference from scratch each time. It is best to cache this reference for efficiency, as shown in the code above.
    • Just to be clear, nearly all of the "automatic references" that have been depreciated, and these include audio.Play();
    [Fixed quote marks - Ed]
     
    Last edited by a moderator: May 21, 2015
  25. Allie_98

    Allie_98

    Joined:
    May 21, 2015
    Posts:
    15
    Thank you so much. This helps me greatly
     
  26. amelior8

    amelior8

    Joined:
    May 21, 2015
    Posts:
    1
    I'm following along with the tutorial and am currently on the seventh video. I found that my ship can fire bolts, but they either stay in the same location or, when moving left or right, slide along the x-axis. My code looks the same as that in the video. I am using 4.3.
     
  27. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    First of all, I'd suggest that you upgrade your version of Unity. 4.3 is very old. Version 4.6 is the most recent version of the 4 series. If it were me, I would upgrade to Unity 5.

    Now, your issue...

    Don't forget there are two faces to this coin, the code side and the editor side. You may have good code, but you will also need to have the scene set up correctly. This means you will need to check not only your script, but check your GameObjects and thier attached Components. Are the proper Components attached to the GameObjects? Are the Collider Components marked correctly? (IIRC, these should be as "triggers"...) Are the values set correctly in the Component fields? If these are not correct, even tho' your code is correct, your game will not behave as expected.
     
  28. Allie_98

    Allie_98

    Joined:
    May 21, 2015
    Posts:
    15
    I have another error:

    Here is my code(C#):
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    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.         if (gameControllerObject != null)
    16.         {
    17.             gameController = gameControllerObject.GetComponent<GameController>;
    18.         }
    19.         //insurance policy
    20.         if (gameController == null)
    21.         {
    22.             Debug.Log ("Could not find 'GameController' script");
    23.         }
    24.     }
    25.  
    26.     void OnTriggerEnter (Collider other)
    27.     {
    28.         if (other.tag == "Boundary")
    29.         {
    30.             return;
    31.         }
    32.  
    33.         Instantiate(explosion, transform.position, transform.rotation);
    34.  
    35.         if (other.tag == "player")
    36.         {
    37.             Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
    38.         }
    39.  
    40.         gameController.AddScore (scoreValue);
    41.  
    42.         Destroy (other.gameObject);
    43.         Destroy (gameObject);
    44.     }
    45. }
    46.  
     
  29. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    The clue to this is in the message associated with the error:
    You have forgotten the paraentheses at the end of this line:
    Code (csharp):
    1.  gameController = gameControllerObject.GetComponent<GameController>;
    As this is calling or invoking a function, you need the parentheses which are part of the function's signature:
    Code (csharp):
    1.  gameController = gameControllerObject.GetComponent<GameController>();
    Probably worth double checking the video closely when you see these errors, or comparing the code with the finished scripts that are in the project's "done" folder, or the finished scripts included on the page where the video is embedded on the learn site. These will show you what the code should be, and you'll find your mistakes faster than posting here on the forum.

    Now, if you really are stuck, post! But it may be quicker to check the available resources first.
     
  30. Allie_98

    Allie_98

    Joined:
    May 21, 2015
    Posts:
    15
    Okay, I just finished coding my 2D Space Shooter. And in the last tutorial it talks about FTP Client... What is an FTP? How can i get one? And what is the best recommendation for an FTP Client?
     
  31. NobleRogue

    NobleRogue

    Joined:
    Apr 20, 2015
    Posts:
    8
    I figured it out last week. You need to add * speed to line 20. "rb.velocity = movement * speed;". or for you "rig" in stead of rb. and you are going to want to add a public float for speed. "public float speed;".
     
  32. NobleRogue

    NobleRogue

    Joined:
    Apr 20, 2015
    Posts:
    8
    I have been staring at this screen for hours now. I just cant seem to figure it out.
    Error 1: Assets/Scripts/DestroybyContact.cs(11,26): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected
    Error 2: Assets/Scripts/DestroybyContact.cs(11,17): error CS1502: The best overloaded method match for `UnityEngine.Object.Destroy(UnityEngine.Object)' has some invalid arguments
    Error 3: Assets/Scripts/DestroybyContact.cs(11,17): error CS1503: Argument `#1' cannot convert `object' expression to type `UnityEngine.Object'

    Code (CSharp):
    1. public class DestryByContact : MonoBehaviour
    2.  
    3. {
    4.     void OnTriggerEnter (Collider other)
    5.     {
    6.         Destroy (other.gameObject);
    7.         Destroy (gameObject);
    8.      }
    9. }
    I have looked up the current coed for "OnTriggerEnter" and the only difference is:
    {
    void OnTriggerEnter (other : Collider)
    Destroy (other.gameObject);
    }

    I tried this coed but I still had compiler issues.
    Code (CSharp):
    1. public class DestryByContact : MonoBehaviour
    2.  
    3. {
    4.     void OnTriggerEnter (other : Collider)
    5.     {
    6.         Destroy (other.gameObject);
    7.         Destroy (gameObject);
    8.     }
    9. }
    This is the Error message I get: Assets/Scripts/DestryByBoundary.cs(7,30): error CS1041: Identifier expected

    I tried doing the "done" script for this but I have not gotten so far as to create a gameController or the gameController script. So I eliminate all of the coed having to do with thing I have not gotten to yet, I am left with the fist coed I posted. It would seem as though the "Done" scrips in the assets package have not yet been updated to be 5.0 compliant. Pleas help. And pleas be descriptive as to why the steps I need to take are necessary. I'm still learning. Thank you very much for any and all help.
     
    Last edited: May 23, 2015
  33. NobleRogue

    NobleRogue

    Joined:
    Apr 20, 2015
    Posts:
    8
    LMFAO, pleas disregard this post. My issue was not in this coed. I mistakenly altered the coed in the "DestroybyBoundary" script while trying to write this one. Stupid mistake even for a noob like myself.
     
  34. erik_1994

    erik_1994

    Joined:
    May 23, 2015
    Posts:
    2
    Hi everyone,
    I've the same problem as paul81, and I've done all of Adam 's suggestion but still no shooting :<

    Code (CSharp):
    1. [Serializable]
    2. public class Boundary
    3. {
    4.     public float xMin, xMax, zMin, zMax;
    5. }
    6.  
    7. public class PlayerController : MonoBehaviour
    8. {
    9.     public float speed;
    10.     public float tilt;
    11.     public Boundary boundary;
    12.     Rigidbody rb;
    13.     void FixedUpdate()
    14.     {
    15.  
    16.         float moveHorizontal = Input.GetAxis("Horizontal");
    17.         float moveVertical = Input.GetAxis("Vertical");
    18.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    19.  
    20.         // set the speed for the ship
    21.         rb.velocity = movement * speed;
    22.         // set the boundary for the ship
    23.         rb.position = new Vector3
    24.             (
    25.             Mathf.Clamp(rb.position.x, boundary.xMin, boundary.xMax),
    26.             0.0f,
    27.             Mathf.Clamp(rb.position.z, boundary.zMin, boundary.zMax)
    28.             );
    29.         // make the ship tilt when move x
    30.         rb.rotation = Quaternion.Euler
    31.             (
    32.             0.0f,
    33.             0.0f,
    34.             rb.position.x * -tilt // -tilt for not tilting at opposite direction
    35.             );
    36.  
    37.     }
    38.  
    39.     public GameObject shot;
    40.     public Transform shotSpawn;
    41.     public float fireRate;
    42.  
    43.     private float nextFire;
    44.  
    45.     void Update()
    46.     {
    47.         if (Input.GetButton("Fire1") && Time.time > nextFire)
    48.         {
    49.             nextFire = Time.time + fireRate;
    50.             Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
    51.  
    52.         }
    53.     }
     
  35. Mega_Jimmy

    Mega_Jimmy

    Joined:
    May 12, 2015
    Posts:
    9
    Figured out my Issue; forgot to set the Player object as a Collider *bright red blush* Whoops. Thanks anyway!
     
    Last edited: May 25, 2015
  36. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Are you getting any errors in the console?
     
  37. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Great. Good to hear.
     
  38. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Be aware of the differences in language. Unity supports C# and UnityScript: (aka: JavaScript). These two languages have similar but different syntax.

    This is UnityScript:
    Code (JavaScript):
    1. void OnTriggerEnter (other : Collider)
    This is C#:
    Code (CSharp):
    1. void OnTriggerEnter (Collider other)
    In the documentation you can choose the language for the code examples in the header of the page.

    Don't mix languages in the same script.
     
  39. tvance929

    tvance929

    Joined:
    May 15, 2015
    Posts:
    14
    Please forgive me if this has been asked before but is there ANY WAY to get ahold of that SPEED variable on the hazard in the SpawnWaves function? I would so like to be able to pump that up just a bit with each progressive wave.

    I know we are instantiating a prefab so this my be impossible... I was hoping I could somehow cast it as the prefab :

    hazard = Resources.FindObjectsOfTypeAll(typeof(GameObject)).Cast<GameObject>().Where(g=>g.tag=="Asteroid");

    and then reassign the Speed... but no go. Help?
     
  40. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    When you instantiate a new object, the instantiate function returns an object reference. You can use this object reference to access the components on the object. You will need to cast this object as the component type you are looking for.

    Code (csharp):
    1. HazardController clone = Instantiate (hazard, spawnPosition, spawnRotation) as HazardController;
    2. clone.speed = 10^50;
     
  41. tvance929

    tvance929

    Joined:
    May 15, 2015
    Posts:
    14
    First of all...THANK YOU! You guys are awesome! Secondly, I am not quite able to get it to work... I tried using MOVER since I dont have a HazardController...wasnt sure how I should implement that/what to put in it. Using the mover class, i get ONE asteroid... so thats something. :)

    Here is what I was trying:
     
  42. tvance929

    tvance929

    Joined:
    May 15, 2015
    Posts:
    14
    Got it! Was able to figure it out because of your other stuff, DestroyByContact.cs. Thanks a ton!

     
  43. Wabefuhon

    Wabefuhon

    Joined:
    May 27, 2015
    Posts:
    13
    I may have a solution. The below is how I code.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. [System.Serializable]
    4. public class Boundary{
    5.     public float xMin, xMax, zMin, zMax;
    6. }
    7. public class PlayerController : MonoBehaviour {
    8.     public float speed;
    9.     public float tilt;
    10.     public Boundary boundary;
    11.     Rigidbody rb;
    12.     public GameObject shot;
    13.     public Transform shotSpawn;
    14.     public float rtf = 0.5f;
    15.     private float nfr = 0.5f;
    16.     void Update(){
    17.         if (Input.GetButton ("Fire1") && Time.time > nfr) {
    18.             nfr = Time.time + rtf;
    19.             Instantiate (shot, shotSpawn.position, shotSpawn.rotation);
    20.         }
    21.     }
    22.     void Start(){
    23.         rb = GetComponent<Rigidbody> ();
    24.     }
    25.     void FixedUpdate(){
    26.         float moveHorizontal = Input.GetAxis ("Horizontal");
    27.         float moveVertical = Input.GetAxis ("Vertical");
    28.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    29.         rb.velocity = movement * speed;
    30.         rb.position = new Vector3 (
    31.             Mathf.Clamp (rb.position.x, boundary.xMin, boundary.xMax),
    32.             0.0f,
    33.             Mathf.Clamp (rb.position.z, boundary.zMin, boundary.zMax));
    34.         rb.rotation = Quaternion.Euler (0.0f, 0.0f, rb.velocity.x * -tilt);
    35.     }
    36. }
    37.  
    My issue at this point is that the lasers don't show up on the Game screen but do show up on the Scene screen. This means I need to backtrack to tutorial 6.

    Edit:
    I discovered while dragging Bolt into Hierarchy. The Bolt shows up, but it doesn't move. In Script it moves, but in Game it doesn't. Even worse is that it doesn't even show up in Game when shooting.
     
    Last edited: May 27, 2015
  44. pwnsdisease

    pwnsdisease

    Joined:
    May 27, 2015
    Posts:
    5

    Hey, OboShape,

    I was having the same problem that farber was and you fixed it but there was something curious about the tutorial video. Granted it was in Unity 4 but when I looked at the video again he doesn't have the Convex and Is Trigger check boxes checked and yet he can still see the collider in his Scene view. wtf is that all about lol

    Also, to Adam,

    Great videos man! I am learning a lot from them and I know almost nothing coming into this, especially about coding. Is there anything on the agenda about updating these project videos for Unity 5? It may not seem like an issue but I foresee one where the discrepancies between coding in Unity 4 versus Unity 5 causing serious translation problems from the videos to the current practices. I personally don't know enough about coding to be able to understand the depreciation taking place between the two version's coding. I am a fast learner and am trying to absorb all I can but it seems the community would benefit better from an updated video better and faster than they would having to stop and consult the forums every inch of the way.

    I site AlbertoNieto's post on April 14th where he had to explain that, in Unity 5 audio.play (); becomes GetComponent<AudioSource>().Play(); as an example.

    I am not sure I would have understood that was an issue at all if I hadn't happened to read that post.

    Once again, I love the site, love the resources, and I love the videos. You guys have done a great job so far. I don't want anyone to think I am being harsh or anything. If these aren't even issues then I might just not know that because I am still at a beginner level.
     
  45. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Sorry - that was me using somewhat invented back-pocket pseudo-code so you could get the idea.

    If the script that you need to get a hold of is Mover.cs, then the Type will be "Mover", so yes:
    Code (csharp):
    1. Mover clone = Instantiate (hazard, spawnPosition, spawnRotation) as Mover;
    2. clone.speed = 10^50;
     
  46. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You can cut the "GetComponent" step if you cast the instantiated object to "Mover" iirc. That being said, what you did works fine.
     
  47. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Have you checked the orientation of the shot? As it's a quad, could it be facing another direction than in the tutorial? It needs to be oriented to face the camera, and the parent object and collider need to be oriented to move along the x-z plane.
     
  48. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    The "convex" box is a new requirement for Physics in this case with Unity 5.

    I can't remember which items need to be marked "Is Trigger = true" but it should be correct in the video.

    The collider being visible is not related to "Is Trigger" but it's related to whether or not the Component is visisble / exposed. If you collapse the Component view, you will hide the gizmo.

    We are not planning on updating Space Shooter to Unity 5, but I do plan on more in-depth upgrade information on the project.

    The change in audio.play() to GetComponent<AudioSource>().Play (); is documented in the original post in this thread, and should be annotated on the video. I plan to add these steps to the emedding page as well.

    Thanks for the feedback! (^_^)
     
  49. erik_1994

    erik_1994

    Joined:
    May 23, 2015
    Posts:
    2
    Oh it work now
    I 've found out that my bolt was falling down instead of moving forward.
    Of course, the rotation of the bolt had been changed
    My bad :<
    Thanks for the feedback :)

    Also to Wabefuhon
    I've found out that I was missing " rb = GetComponent<Rigidbody>(); "

    Thanks guys
     
  50. ricardopadua

    ricardopadua

    Joined:
    May 30, 2015
    Posts:
    4
    Hello Guys.

    I've followed the tutorial on space shooter project and it works fine on the editor. But when I build it to Android the bolts are sometimes not displaying on the screen. They are firing and destroying the asteroids but sometimes they are visible and sometimes not. It's like is skipping some frames maybe. I'm using Unity 5.0.1f.

    Does anyone knows how to fix that?