Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    Dismiss Notice

Space Shooter Tutorial Q&A

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

  1. ricardopadua

    ricardopadua

    Joined:
    May 30, 2015
    Posts:
    4
    Nevermind. I've updated Unity to version 5.0.2f and now works fine.
     
  2. bucnasti

    bucnasti

    Joined:
    May 31, 2015
    Posts:
    2
    I've just finished the Space Shooter Tutorial and when I run the game it crashes. I've tried it both in the web player and in the standalone. It works perfectly in the editor, but when I build and run it the music starts and then I get a message that it crashed.

    I'm using Unity 5.0.2f1 my logs are attached.
     

    Attached Files:

  3. bucnasti

    bucnasti

    Joined:
    May 31, 2015
    Posts:
    2
    I figured out my crash. When I was building the game there was an extra scene in the list that didn't actually exist. Once I deleted that and rebuilt the app it worked fine.
     
  4. OwiHH

    OwiHH

    Joined:
    May 18, 2015
    Posts:
    2
    You missed that the lesson is for webplayer and not for any other device. I think thats the point you get some errors and the teacher says: "6 - sit down" :D .. no offense ..
     
  5. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Are you still having an issue with android? Have you tried a standalone or web build to verify that the game only fails on android? There are no know issues where android fails, so if you continue to have issues, we need more details.
     
  6. Tayd3ll

    Tayd3ll

    Joined:
    Jun 4, 2015
    Posts:
    13
    Hey guys i've been doing the space shooter tutorial and im really happy to learn more about Unity.. I have come across a problem that i have spent some time trying to fix on my own but could not. For some reason when i add a capsule collider to the Asteroid "Empty GameObject" it moves the transform position out of the reset position aswell as the rotations.
    i would be very gratefull if anyone had any idea why this was happening!
    thankyou in advance.
     
  7. yihiit

    yihiit

    Joined:
    Jun 3, 2015
    Posts:
    1
    Hello everyone,

    I`ve been doing this space shooter tutorial and came up with a problem in the 14th part.

    I did exactly everything in the 14th video, wrote all the scripts and did all the settings from the inspector menu, but whatever I do, the score text doesn`t go up when I shoot the asteroids.

    It just stays as Score: 0, all game long.

    I have no console errors, could someone show me what I`m doing wrong?

    I`m using Unity 5 btw.
     
  8. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This sounds strange. Can you supply us with either a set of screenshots or a short screen capture video of what's going on? This doesn't make sense to me, but I may be missing something.
     
  9. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This could be a number of issues. I'd start by tracing the "chain" of events to see what the issue is. You can either start from the function that updates the score and move bakwared towards the GameObjects involved, or you can start with the Asteroids and work towards the collisons... Ask yourself questions like "Have I assigned the correct value to each asteroid Prefab?" and then check that value. If yes, then check to see if the trigger contact is happening (which should be true if they are destroyed). If this is true, are the tags correct? Keep working down the chain of events until you find the actual issue. But! Don't take random stabs at it: "Hey, what about this? or even this?" Work methodically from one end to the other in the chain of logic.

    A fall back would be to check your scripts and GameObjects against the "done" versions, or rewatch the video again and triple check everythig: check the steps in code AND the editor. Check spelling and capitalization. If you have a misspelled function, it may not be called, but won't throw and error.

    If you have any specifics that we can use, we can try to help as well.
     
  10. Tayd3ll

    Tayd3ll

    Joined:
    Jun 4, 2015
    Posts:
    13
    Thankyou for replying and i added a picture of the steps i did when the problem cam up and i believe i followed them exactly but the word file shows pictures of everything i click and the values of the transform afterwards
     

    Attached Files:

  11. Amoebozoa

    Amoebozoa

    Joined:
    Jun 2, 2015
    Posts:
    16
    I've ran into a bit of an issue for no apparent reason, after lesson 15 and adding the code to add score to the game, my player character no longer explodes if it collides with the asteroids, I changed nothing to the code about them colliding only added the code for the score.

    The current error is this "UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineObject.gen.cs:60)"

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DestroyByContact : MonoBehaviour
    5.     {
    6.     public GameObject explosion;
    7.     public GameObject playerexplosion;
    8.    
    9.     public int scoreValue;
    10.     private 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.         if (gameController == null)
    20.         {
    21.             Debug.Log ("Cannot find 'GameController' script");
    22.         }
    23.     }
    24.  
    25.         void OnTriggerEnter(Collider other)
    26.         {
    27.             if (other.tag == "Boundary")
    28.             {
    29.                 return;
    30.             }
    31.         Instantiate (explosion, transform.position, transform.rotation);
    32.         if (other.tag == "Player") {
    33.             Instantiate (playerexplosion, other.transform.position, other.transform.rotation);
    34.         }
    35.             Destroy(other.gameObject);
    36.             Destroy(gameObject);
    37.         }
    38.     }
    Ontop of that I would just like to point out that you in the 8th lesson you have added a
    Code (CSharp):
    1.  
    2.             audio.Play ();
    for the shots which will cause errors untill people get to the audio lesson.
     
  12. spagett39

    spagett39

    Joined:
    Jun 9, 2015
    Posts:
    1
    I'm having trouble with video 7: creating shots and please forgive me if this problem has already been posted (I did check). My bolts are firing fine while I move the ship some side to side, but if I fire while the ship moves forward or backwards, the bolts disappear after awhile. It seems like they're colliding into each other and disappearing or something. I've noticed that this only occurs when my 'Boundary' game object is active (which is used to destroy the bolt once it leaves the screen). If I deactivate boundary, the bolts fire just fine regardless of what direction I'm flying the ship.

    I could write code in the bolt prefab that destroys bolt after it travels X number of units along the Z axis, but I don't want to have to write this same code for asteroids, enemies, bullets, etc. that will also be populated in the game later. Gravity is currently turned off in the bolt prefab's rigidbody properties. Any thoughts?
     
  13. Tayd3ll

    Tayd3ll

    Joined:
    Jun 4, 2015
    Posts:
    13
    I figured out what i was doing wrong and have fixed. thanks for all the help guys=) it was just something dumb i did... i didnt turn boundary into a trigger and the asteroid was colliding with it.
     
  14. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I don't recognize this error as being a user created issue... I'm looking into it...

    Is this the complete error? Could there be more to the error? This looks like it's missing something... It seems to indicate the location of the error, but not the error itself.

    Is this in the VIDEO lesson? Or is this in the code examples on the lesson's page?
     
  15. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Surprisingly easy to do... missing these tiny steps. It will make more sense when you're doing your own project, rather than following someone else's!
     
  16. Amoebozoa

    Amoebozoa

    Joined:
    Jun 2, 2015
    Posts:
    16

    In the code underneath the video, granted it's not in the actual video, but if someone copies the code rather than write their own they are going to get spammed with errors.
     
  17. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I'd suggest going back and looking at the video again, and double checking your steps. The code and setup should work fine if you've gotten all the details correct. Writing a work-around might only bite you in the back pocket later.

    Don't forget you need to follow the steps to not only write the code, but to arrange the details of the components on the game objects correctly.
     
  18. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Ah - that makes sense. I'll go look. That should have been cleaned to match the episode, but it could have slipped thru.

    Thanks!
     
  19. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Regarging the other half of the question, @Amoebozoa:

    "I don't recognize this error as being a user created issue... I'm looking into it...

    Is this the complete error? Could there be more to the error? This looks like it's missing something... It seems to indicate the location of the error, but not the error itself."
     
  20. Amoebozoa

    Amoebozoa

    Joined:
    Jun 2, 2015
    Posts:
    16
    Right I apparently missed a bit of it, I am sorry about that, here's the rest of the error message


    "UnassignedReferenceException: The variable playerexplosion of DestroyByContact has not been assigned.
    You probably need to assign the playerexplosion variable of the DestroyByContact script in the inspector.
    UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineObject.gen.cs:60)
    UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:80)
    DestroyByContact.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Scripts/DestroyByContact.cs:33)"
     
  21. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Ah - that makes more sense.

    You not assigned your explosion!

    ( From the error: )
    You probably need to assign the playerexplosion variable of the DestroyByContact script in the inspector.
     
  22. Amoebozoa

    Amoebozoa

    Joined:
    Jun 2, 2015
    Posts:
    16
    So it un assigned itself? Since I had it working before, I'l check that out and report back.

    Yep it had apparently unassigned itself, but readded it and now it works. Thanks
     
  23. marigold-mare

    marigold-mare

    Joined:
    Jun 10, 2015
    Posts:
    5
    Hi there -
    Hopefully someone here can point my in the right direction.
    I'm having trouble getting the asteroid to move forward with the Mover class. (Tutorial #11)..
    Adding the Mover script also stops the RandomRotator script from running.

    Everything else seems to work - explosions, shots, etc.

    I'm currently using this format for accessing the "rbs"- so perhaps this is part of the problem?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class RandomRotator : MonoBehaviour {
    5.  
    6.     public Rigidbody rb;
    7.     public float tumble;
    8.     void Start ()
    9.     {
    10.         rb.angularVelocity = Random.insideUnitSphere * tumble;
    11.  
    12.     }
    13. }
    14.  
     
  24. marigold-mare

    marigold-mare

    Joined:
    Jun 10, 2015
    Posts:
    5
    Looks like I just had "Is Kinematic" accidentally switched on. Works fine now.

    Takes some getting used to..
     
  25. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Ya, it's easy when learning and playing with a component to accidentally click a check box and change a setting that one didn't expect or want to.

    It does just take getting used to!

    Glad you figured it out.
     
  26. marigold-mare

    marigold-mare

    Joined:
    Jun 10, 2015
    Posts:
    5
    Thanks, Adam!

    I was thinking it would be cool to make the bolts rotate in circles after they are fired - but I'm having a little trouble figuring it out. Do you have any suggestions?
     
  27. marigold-mare

    marigold-mare

    Joined:
    Jun 10, 2015
    Posts:
    5
    Right now, I'm using this, which is sort of cobbled together - any pointers in terms of efficiency and "what the hell am I doing?" would be appreciated.
    Code (CSharp):
    1.  
    2.  
    3. public class RotaMover : MonoBehaviour {
    4.     public Vector3 ab;
    5.     private Vector3 boo;
    6.     private Rigidbody rb;
    7.     public float speed;
    8.     // Use this for initialization
    9.  
    10.     void Start () {
    11.         rb = GetComponent<Rigidbody>();
    12.         rb.velocity = transform.forward * speed;
    13.  
    14.     }
    15.  
    16.     void Update () {
    17.  
    18.         boo = new Vector3(Random.Range (-0.5f, 0.5f), Random.Range (-0.5f, 0.5f), Random.Range(-0.5f, 0.5f));
    19.         transform.Rotate(ab);
    20.         transform.position = (rb.position+boo);
    21.         transform.localScale = transform.localScale + boo;
    22.     }
    23.  
    24.  
    25.  
    26.  
    27. }
     
  28. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I'm not sure I understand what you mean by rotate in circles... Can you describe thus in a different way, or draw a picture?
     
  29. marigold-mare

    marigold-mare

    Joined:
    Jun 10, 2015
    Posts:
    5
    Well, I'm interested in what it would entail to fire shots with different patterns - circles or otherwise - in order to better understand some of the Transform/Translate structures of working in 3D. Is there something you'd recommend outside of the tutorial to better understand this?
     
  30. Dr.FortuneC

    Dr.FortuneC

    Joined:
    Jun 11, 2015
    Posts:
    4
    Help i can't make the spaceship black with this settings.. i tried copying from the Done scenes files and still not working .. please do check thanks. (
    i tried making the ambient and reflection intensity to 0 and still not having any changes.
     

    Attached Files:

  31. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    This is because unity now includes a default directional light in every new scene. You can see this in the hierarchy. Use this as your key light.
     
  32. LastNumber

    LastNumber

    Joined:
    Jun 16, 2015
    Posts:
    3
    I'm on lesson 8 and when I try to play the game with the code on for Unity 5 it keeps saying the script is missing and when I play the game, the lasers keep going and the boundary doesnt work.
     
  33. janderson8888

    janderson8888

    Joined:
    Jun 16, 2015
    Posts:
    1
    I'm having an issue with the respawing of the asteroids. When the asteroid is in the Game Hierarchy it collides and blows up fine. However when the waves are re-spawned, the bolts just pass through as if they don't have colliders on the clones. All my code is up to date as of lesson 13. I think it is an issue of the Unity that I am using. (5.0.2f1). Have there been others with this issue who tried to do this project?
     
  34. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Is there any chance you do have a script missing. Double check each step to make sure you've not missed something. If you need to, check your code against the sample code of the lesson page or in the "done" folder. When it comes to "missing scripts", this means you could have written it, and the code is correct, but it's not attached to the gameobject properly.
     
  35. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Sadly, it won't be the version of Unity.

    If you have made changes to the prefab and the prefab works in the hierarchy, you also need to make sure that those changes are "applied" to the prefab, or the prefab asset will be different from the one in the scene.

    Don't forget that there are two major faces to Unity: the code and the scene. You can have prefect code, but have the scene object assembled wrong. Or you could have an issue with the construction of the assets and prefabs. Double check your steps, keeping an eye on your scene construction and assets.

    Don't forget you can compare your scene with the "done" version in the project.
     
  36. LastNumber

    LastNumber

    Joined:
    Jun 16, 2015
    Posts:
    3
    It still wont stop my shots, they still keep repeating in my hierarchy and my scripts in the Done folder dont affect my shots at all.
     
  37. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    The point To the comment was to check your code against the code in the done folder, and as I said to Janderson8888 above:

    In your case, you may have deleted or replaced a script. If you have a missing script warning, you need to make sure the script is in place. If you need more detailed help, you will have to give us more detailed information.
     
  38. LastNumber

    LastNumber

    Joined:
    Jun 16, 2015
    Posts:
    3
    Ok my boundary is working now that ive used the script from the Done, but bolt still come my hierarchy as clones. Is that okay or do I need to make another script.
     
  39. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Well, I'm unclear exactly what step you are on. You don't need to create a script for no reason. Each one of the steps in the video is correct, and you need to follow each step exactly, but you can't just arbitrarily add steps or things will become confused.

    Now, if you are worried that you see "Bolt (clone)" I your hierarchy, this is to be expected. If we think for a moment, when we instantiate the Bolt when we fire, it is a GameObject in our scene, right? So this GameObject needs to be in our hierarchy. The suffix (clone) is there to remind us that this GameObject was created at runtime as a copy or clone of another GameObject, in this case the prefab in the assets directory. You can change this name if you want, but it will take additional code.
     
  40. alessandro78

    alessandro78

    Joined:
    Aug 4, 2014
    Posts:
    5
    Hallo Guys

    i have an issue in the display correctly the text position of the score

    as you can see from the immages in attach
    the text for the score is correctly alligned in the canvas in the left-botton corner
    it is alligned right in the scene view and in the game view
    but when i build the game and run it the correct allignment is lost
    any advice?

    Game.png scene.png game build and run.png
     
  41. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    It looks like your score text element is anchored to the center of your screen not the corner, so when youenter play-mode and play-mode is set to maximize, the screen size changes, but the text element does not, as it's anchored to the center.

    Try anchoring it to the corner.
     
  42. LegacyOfWax

    LegacyOfWax

    Joined:
    Jun 12, 2014
    Posts:
    13
    Hi All,

    So I was doing really well getting this game to work in unity 5 without any additional help. Then this happened, on "Creating hazards".
    After writing my script for the tumbler in random rotation script of the Astoriod and I go to play test. the Astoriod rotates, but really slowly. In the scene view I can see the Capsule Collider spinning at the rate it should be but the Astoriod going at a much slower speed.

    code below:

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class RandomRotator : MonoBehaviour
    6. {
    7.     public float tumble;
    8.     public Rigidbody rb;
    9.  
    10.     void Start()
    11.     {
    12.         rb = GetComponent<Rigidbody>();
    13.         rb.angularVelocity = Random.insideUnitSphere * tumble;
    14.     }
    15. }
    16.  
    Thanks for any help!!

    Edit: adding a link to a video to show the issue I seem to be having

    WAX
     
    Last edited: Jun 23, 2015
  43. lawrencemajmacdonald

    lawrencemajmacdonald

    Joined:
    Jun 23, 2015
    Posts:
    1
    Hi, I'm having the exact same issue that spagett39 was having, basically with the boundary active, when firing shots while moving up and down, the shots are destroyed almost immediately. I've rewatched the relevant videos and even gone through every single piece of code and in-console inspector values for each object with the Done version of the game and nothing is different. Any idea what could be causing this?

    Quick gif of the behaviour if you want to see exactly what's going on:
    EDIT: I fixed it, so if anyone else has this problem, it's probably because you did what I did and tried to make the ship rotate along the z-axis when moving forward/back, causing your shots to shoot at an up/down angle, thus exiting the boundary pretty much straight away.
     
    Last edited: Jun 23, 2015
  44. ZeTiXaR

    ZeTiXaR

    Joined:
    Jun 6, 2015
    Posts:
    1
    (I'm not sure if this is the right place to ask this question or not...)
    In lesson 10 for the following code the instructor says that there is no need to have [Destory(gameObject);] line at the end of the code since 'Destory' does not immediately remove the object but it marks the object "to be destroyed". He also mentions that by adding 'return' to our 'if' statement we simply prevent our code to continue executing the rest of the code.
    My question is: When we put 'Destory(gameObject);' line at the beginning of our code it still works like when we have it at the end of the code or before 'Destroy(other.gameObject);'. I was expecting when we have 'Destroy(gameObject);' at the beginning of our code, the compiler would mark the object as 'to be destroyed' and as soon as it reaches 'return', destroys the object but the object remains in its place until we shoot it. How is that?

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class DestroyByContact : MonoBehaviour
    6. {
    7.     void OnTriggerEnter(Collider other)
    8.     {
    9.         if (other.tag == "Boundary")
    10.         {
    11.             return;
    12.         }
    13.         Destroy(other.gameObject);
    14.         Destroy(gameObject);
    15.     }
    16. }
     
  45. HaakonXCI

    HaakonXCI

    Joined:
    Dec 14, 2014
    Posts:
    3
    Update: I found out what has changed. In the new version of Unity, when you create an audio source component, there will be a "Spatial Blend" property that has a 2D-3D slider. Thanks anyways for the help.

    Hi, I've been following the video tutorial and I've run into an issue that I can't seem to figure out since the video was made with the older version of Unity. In video #13 (Audio), the option for "3D Sound" is not there in the inspector as it is shown in the video.
     

    Attached Files:

    Last edited: Jun 26, 2015
  46. Shift8studio

    Shift8studio

    Joined:
    Jun 26, 2015
    Posts:
    2
    Okay, I think this is an issue where Unity 4 and Unity 5 scripting is having a problem. I've tried to compile just 14 lines of code and I get an error. The only difference I can see is that on the tutorial the code: rigidbody is a lower case "R"while in the code I am using on Unity 5 the R is upper case. I've looked in the documentation using CTRL+' but no luck. I'm attaching the snippets from my code and the tutorial code. as examples


    Tutorial Code:


    My Code:
     
  47. DCP81

    DCP81

    Joined:
    Jun 21, 2015
    Posts:
    1
    Hey Guys

    I'm having issues with the bolt not moving, I think it may be due to the differences in Unity 5. The script I'm using is below

    using UnityEngine;
    using System.Collections;

    public class Mover : MonoBehaviour {


    public float speed;
    private Rigidbody rb;

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



    }

    I've set the speed to 10 and the bolt just sits there. My settings in Unity are below. Any ideas??
    Space Shooter.png
     
  48. Indoril_Nerevar

    Indoril_Nerevar

    Joined:
    Jul 2, 2015
    Posts:
    1
    Just one question to start: can we do with the standards assets that comes with unity 5?
     
  49. Galafreed

    Galafreed

    Joined:
    Jul 2, 2015
    Posts:
    2
    Hello there. Hope this is the right place forums are quite segmented. I'm in the middle of doing this tutorial and I've ran into difficulties. I have no prior experience with coding and have been using unity for less than a week as a bit of a hobby. I'm currently writing the PlayerController Script, I save script and return to find the console empty, but when i press play i get an error than starts to climb in number. I have a feeling it may be a setting relating to the object as opposed to the script working. Tried to lookup a solution but no joy. If anyone has any insight that would be great.

    Gala

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

    using UnityEngine;
    using System.Collections;


    public class Boundary
    {
    public float xMin, xMax, zMin, zMax;
    }

    public class PlayerController : MonoBehaviour
    {
    public float speed;
    public float tilt;
    public Boundary boundary;

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

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

    GetComponent<Rigidbody>().position = new Vector3
    (
    Mathf.Clamp (GetComponent<Rigidbody>().position.x, boundary.xMin, boundary.xMax),
    0.0f,
    Mathf.Clamp (GetComponent<Rigidbody>().position.z, boundary.zMin, boundary.zMax)
    );


    }
    }
     
  50. dvir45014501

    dvir45014501

    Joined:
    Jun 14, 2015
    Posts:
    11
    Hi, i hope this is the right place to ask my question,

    in tutorial 10 the code DestroyByContactunder doesn't work for me,

    the code does return after the object is touching the boundary, but it is never reaches the other part of the "if".
    i think its because the object is constantly thouching the boundary and so it's the only thing to be detected.
     
unityunity