Search Unity

Space Shooter Tutorial Q&A

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

  1. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Just wondering have you had a look at Adams live session on resolution and device independence for handy tips?
    http://unity3d.com/learn/tutorials/...ng-archive/resolution-and-device-independence

    the UI in screenspace is an overlay and is displayed infront of everything else.
    for the black kind of bars either side, you could put black sprites on your UI and build it from that, so that it will mask anything behind it, and build up your UI with score health etc on that.
     
  2. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Ah, Interesting. I'll have a look at this...
     
  3. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    @trackpoth You could also have multiple cameras, or you could limit the viewport on your main camera. This way, you could make black bars on the sides where the main camera doesn't render.

    Before you get into device resolution, it's also worth reading articles like this one:
    http://theantranch.com/blog/some-issues-with-optimizing-your-game-to-all-resolutions/
     
    OboShape likes this.
  4. trackpoth

    trackpoth

    Joined:
    Dec 25, 2015
    Posts:
    2
    Will check those out, thank you a lot :)
     
  5. takamuramamoru

    takamuramamoru

    Joined:
    Feb 14, 2016
    Posts:
    8
    Hello again , I don't know if I'm posting in the right forum,but, if possible please help me out.

    I have completed creating 4 games by following tutorials, I have mostly imported the assets from asset store.my doubt is: mostly the animation,graphics is already given for the games in tutorials,but,if I wanna start creating my game do I have to create models,if yes then how do I create them.For example in space shooter tutorial : the space ship,asteroids,background photo were given.so, if I create my own game how do I create the models.Can I create the models using unity.

    p.s:here I'm referring to animation of objects like asteroids not mesh associated with them
     
  6. takamuramamoru

    takamuramamoru

    Joined:
    Feb 14, 2016
    Posts:
    8
    sorry , if my above question was confusing ,simply put,I just want to know the process for creating your own assets;
    including art for various objects
     
  7. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
  8. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yes, you need to create, find or buy your own assets.

    Think of Unity as the "editor". If you were making a movie, the editor (Final Cut Pro, Avid, Premiere, etc.) would be the software to assemble your movie from footage shot on set, still images, titles, credits, sound effects, music, etc. You would need to go write the script, cast the actors, shoot the movie, record the sound, compose and conduct the music, create the visual effects... and then put it all together in the editor.

    The same is true of Unity.

    In Unity you will be able to build your game from all the pieces you create, find, buy, commission... but it is not an asset design or asset creation tool. Unity provides certain primitive shapes in 2D and 3D, but it's focus is not asset creation. For asset creation, you would need to look into Gimp or Photoshop for still images or 2D sprites; Blender, Max, Maya, Modo, etc. for 3D Models; a recording device for audio - or use one of the many free or inexpensive stock sound sites on the internet...

    Game creation can be complex, but start simple. Be aware of the cost of your time, as well. You may find it easier to find a free asset, or buy an inexpensive asset, than take days, weeks or months to create them yourself.

    This also depends upon what your strengths are and what you like to do. If you like art, or music, or models - you may find the learning process of making your own assets more fun than making the game itself.
     
  9. takamuramamoru

    takamuramamoru

    Joined:
    Feb 14, 2016
    Posts:
    8
    Thank you for replying, your answer was really helpful.
     
  10. takamuramamoru

    takamuramamoru

    Joined:
    Feb 14, 2016
    Posts:
    8
    can we use the standard assets given by unity to create my game.Also there are many free assets available can I use them to create my game
     
  11. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    @takamuramamoru Yes, the standard unity assets and most assets on the Asset Store are covered under the Unity-EULA. You should read the EULA for complete details, but essentially you are free to use them within your free or commercial games. You just can't re-sell the assets themselves. However, some assets also come with additional third-party license agreements that might include other restrictions. So you should check each asset before you use it to make sure.
     
  12. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    The search for free assets is a common one. If you look there are models, animations, sound effects, you name it... available on the internet. Some are great, but some are rubbish. You'll have to look around.

    This might help get you started:
    http://theantranch.com/blog/resources-for-people-getting-started/
    http://theantranch.com/blog/resources-for-people-getting-started-community/
     
  13. chabode

    chabode

    Joined:
    Jul 12, 2015
    Posts:
    4
    first, i would like to say thank you for creating this awe tutorial but i found an error which i wonder why this happen.

    MissingReferenceException: The object of type 'GameController' 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.

    this kind of error shown after i following the first 15 min of extended tutorial... where did i have missed it?
     
  14. Leoplureodon

    Leoplureodon

    Joined:
    Feb 20, 2016
    Posts:
    1
    Hi all. Not sure if this has been done or asked about, but I have modified the Instanciate/Destroy to use a game object pool for all objects for maximum performance. You can find the project here. It uses the advanced pooling system (not made by me) available here.
     
    stlouis4d likes this.
  15. acoleman98

    acoleman98

    Joined:
    Feb 22, 2016
    Posts:
    4
    Hi I am on Boundary 08 and I am having trouble with the code. This is my code for Destroy By Boundary:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DestroyByBoundary : MonoBehaviour
    5. {
    6.     void OnTriggerExit(Collider other)
    7.     {
    8.         Destroy(other.gameObject);
    9.     }
    10. }
    11.  
    It destroys the clones after they leave the boundary but if I ever stop shooting and all the clones are erased, a error pops up saying " MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it."

    Can anyone help? I have tried using several different lines of code from the Youtube comments but none of them seem to work.
     
  16. KAYUMIY

    KAYUMIY

    Joined:
    Nov 12, 2015
    Posts:
    115
    Thank You bro for your reply
     
  17. KAYUMIY

    KAYUMIY

    Joined:
    Nov 12, 2015
    Posts:
    115
    Can you help me to understand this code?

    /*
    private GameController gameController;
    void Start()
    {
    GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
    if (gameControllerObject != null)
    {
    gameController = gameControllerObject.GetComponent<GameController> ();
    }
    }
    */

    We need a GameController class' object, that is, instance of the GameContoller class because we call a method created in this Class(GameController). Without instance, we cannot call the method GameController. So we created "gameController" variable typed "GameController". However, why we wrote this code, see below:

    /*
    GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
    */

    If I write this source code what is wrong?

    /*
    private GameController gameController;
    void Start ()
    {
    gameController = GetComponent<GameController>();
    }
    */

    gameController object's type is GameController. So, we can access directly like Rigidbody. Previous lessons, we did same thing for Rigidybody object. But in this work, we are doing in different way.

    Sorry if this question has been repeated.
     
  18. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Missing reference exceptions means you are trying to use something that you have not successfully referenced. In your case, you are trying to use the GameController, but when the code tries to do so, it doesn't know where it is. This most likely happens due to a typo or other error in either your code, or setting up your objects in the inspector. You should re watch the last video and double check your steps. Remember, spelling counts and so does capitalisation, as C# is case sensitive.

    As this error specifically says that it has been destroyed, you might want to check that the game controller is set up correctly, is on the correct game object and doesn't have any unexpected components, like a collider, on it.
     
  19. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Pooling is a good idea. We have at least one, if not more, lessons on pooling in the learn section of our website. For a game this size, using instantiate and destroy won't affect the performance of this game, but it is a good habit to get into.
     
  20. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Please ignore all YouTube comments and please use these official forums!

    Most likely you are using a scene object for your bolt and are trying to instantiate the next bolt from a scene object.

    Double check your code and your set up in the inspector to make sure that you are instantiating the prefab from the project view and that you are not replacing this reference with the newly instantiated bolt. If you are taking a GameObject reference from the instantiated bolt, it must be a different variable than the one you are using for your prefab reference, otherwise your ship will try to use the newly instantiate bolt as the template to instantiate the next one.
     
    Vvvvergram likes this.
  21. H_guz05

    H_guz05

    Joined:
    Feb 16, 2016
    Posts:
    3
    Thank you so much for your help!
     
  22. acoleman98

    acoleman98

    Joined:
    Feb 22, 2016
    Posts:
    4
    This is my code for player controller. It looks like I did what you said tell me if I am correct.
    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.  
    11. public class PlayerController : MonoBehaviour
    12. {
    13.  
    14.     public float speed;
    15.     public float tilt;
    16.     public Boundary boundary;
    17.  
    18.     public GameObject shot;
    19.     public GameObject shotSpawn;
    20.     public float fireRate;
    21.  
    22.     private float nextFire;
    23.  
    24.     void Update()
    25.     {
    26.         if (Input.GetButton("Fire1") && Time.time > nextFire)
    27.         {
    28.             shot = Instantiate(shot) as GameObject;
    29.             nextFire = Time.time + fireRate;
    30.             //GameObject clone =
    31.             shot.transform.position = shotSpawn.transform.position;
    32.  
    33.         }
    34.     }
    35.     void FixedUpdate()
    36.     {
    37.  
    38.         float moveHorizontal = Input.GetAxis("Horizontal");
    39.         float moveVertical = Input.GetAxis("Vertical");
    40.  
    41.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    42.         GetComponent<Rigidbody>().velocity = movement * speed;
    43.  
    44.         GetComponent<Rigidbody>().position = new Vector3
    45.             (
    46.                 Mathf.Clamp(GetComponent<Rigidbody>().position.x, boundary.xMin, boundary.xMax), 0.0f, Mathf.Clamp(GetComponent<Rigidbody>().position.z, boundary.zMin, boundary.zMax)
    47.                 );
    48.         GetComponent<Rigidbody>().rotation = Quaternion.Euler(0.0f, 0.0f, GetComponent<Rigidbody>().velocity.x * -tilt);
    49.     }
    50.  
    51. }
     
  23. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    The rigidbody is attached to the GameObject that is looking for it. If we use a "GetCompetent" it find the requested component if it is on this GameObject, or it returns null. To find the component on another GameObject, we need to find the GameObject first. So, with this code, we find the GameObject holding the Component, then (if the GameObject reference is not null) we Get[ the ]Component we are looking for. Does this make sense?
     
  24. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yup! This is exactly the problem I state. You are replacing the value of "shot" with the newly instantiated bolt.

    ps: why not use the code as shown in the lesson?
     
  25. rashid597

    rashid597

    Joined:
    Feb 24, 2016
    Posts:
    3
    My asteroid is not being destroyed by the bolt
    Both the bolt and asteroid are moving forward after colliding and getting destroyed by boundary.
    Also I have checked scripts several times, everything is correct but it's not working.
    Please help me.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DestroyByContact: MonoBehaviour
    5. {
    6.     void OnTriggerEnter(Collider other)
    7.     {
    8.     if (other.tag == "Boundary")
    9.         {
    10.             return;
    11.         }
    12.         Destroy(other.gameObject);
    13.         Destroy(gameObject);
    14.     }
    15. }
     
    Last edited: Feb 24, 2016
  26. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Check that the colliders are triggers. If they are not triggers, they won't respond to OnTriggerEnter.
     
  27. acoleman98

    acoleman98

    Joined:
    Feb 22, 2016
    Posts:
    4
    How would I fix this then? Will I have to rewrite the entire code?
     
  28. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Well. I can't speak to any of the other modifications you've made in the code, but, specific to your issue: First, you create a public member variable called "shot". Then, presumably in the editor, you assign your shot prefab to it. Then, when you fire your weapons, you replace the prefab reference being held in "shot" with a reference to the newly instantiated shot.

    Don't do this.

    Why not set the position as part of the instantiate function? In this case, you won't need a reference to the newly instantiated shot.

    If you keep this code architecture that you currently have, you will need to store the reference to the newly instantiated shot in a different variable, rather than replace your original prefab reference with it.
     
  29. acoleman98

    acoleman98

    Joined:
    Feb 22, 2016
    Posts:
    4
    I feel like it would be more of a issue to continue the code I have now then to restart and use the original code. The only reason why I used the you tube comments for the code is because I couldn't figure out how to update the code for Unity 5.3. The update guide says there are no changes for the "shooting shots" tutorial, yet the position method isn't working for me.
     
  30. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    If there are no notes in the upgrade guide, then it should work as stated in the video.

    This is often the problem with unofficial YouTube comments. Many people erroneously find fixes or workarounds to problems that don't exist.

    If you follow the tutorial step by step it should work as explained. If you are having issues, check the documentation. If I remember correctly, we even show this documentation page in the video.

    When using Instantiate, you have the two overloads - one where you simply instantiate the object (as you have used) and then you need to modify the newly instantiated object by reference. The other overload allows you to instantiate an object with a position and rotation.

    If you couldn't get this second overload to work, rather than work around the issue your created in your code, it would have been best to find the issue and fix it.

    At this point, if you want to keep using your exiting code, which will work, you need to follow my advice above.

    The other option is to copy the code from the official learn page and use that code instead.

    What ever you do, don't rely on random YouTube comments, as they usually cause more harm than good.
     
  31. KAYUMIY

    KAYUMIY

    Joined:
    Nov 12, 2015
    Posts:
    115
    COUNTING POINTS AND DISPLAYING THE SCORE
    I watched it many times. Help me to understand this tutorial. I wrote here what I understood from this tutorial. I am not sure. I would be grateful, if you would check my conclusion.

    Why we cannot drag and drop GameController object from Hierarchy to the DestroyByContact?
    According to the tutorial, we need reference, we need car's ticket. Ticket = reference.
    Our variable typed gameController in DestroyByContact class does not have reference.

    gameController has not reference. So we cannot drag and drop. Is it right?
    We need a new gameObject must have a reference coming from GameController class. After, We can give this reference to our variable which is gameController.

    Thats why, we created new gameObject. And This gameobject holds GameController's reference.
    like this:
    GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
    There is one work we did not do.
    We have to give this reference to our gameController.
    like this:
    gameController = gameControllerObject.GetComponent<GameController> ();

    Now, our variable gameController has a reference to instance of the GameController object.
     
  32. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Did you miss this answer?
    Please read this response first, then read below...
     
  33. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    An asset cannot hold a reference to an object in a scene. Why? There are some deep technical explanations, but think about it... The reference needs to point to a specific instance of an object. An asset in the project window cannot hold a reference to an object in a scene - arguably - that doesn't exist yet. The objects in a scene are crated when we load and run that scene and are destroyed when we leave that scene and load a new one. More importantly, that asset (the enemy prefab, etc.) can be added to any scene in the game and (if we choose to) be packaged up and shared between games, if all the components and dependent assets are packaged with it. It doesn't make sense that the asset can have a reference to a scene object. It's also just not possible.

    No, not unless we set it.

    No, see above as to why you cannot drag and drop a scene object into a field on an asset.

    No. If I understand this correctly, this is partly wrong.

    A newly instantiated GameObject with a public reference to a component or script found in the scene will have to be given the reference to the component or script somehow.

    If you are saying that a newly instantiated asset must find or be given any scene object references after it is instantiated, you are correct.

    I think we are having a mis-communication with the word "create" and "created". We don't create a new GameObject here. We have an existing GameObject reference in our script. This existing GameObject reference does not hold anything until we populate it with a found reference. We need to use the GameObject.Find to find the GameObject we are looking for and set that to BE the reference with: GameObject gameControllerObject = GameObject.FindithTag("GameController");

    Yes, correct.

    We start with an Empty set of references. We need to find the reference by first finding the GameObject with the component and then doing a GetComponent On that GameObject.

    What can be deceptive is that locally, to find a component on the same GameObject we can simply use GetComponent and the GameObject reference is assumed to be the current GameObject if none is specified.

    Does this make sense?
     
  34. rashid597

    rashid597

    Joined:
    Feb 24, 2016
    Posts:
    3
    Thank you but i already found this mistake.
     
  35. ShokeR0

    ShokeR0

    Joined:
    Feb 24, 2016
    Posts:
    112
    Hey, I've been trying to add a new small feature to the game related to the background scrolling.
    So in the start of extending space shooter tutorial he explain how to make the background moving.

    I want to add a small feature when the play complete a wave (I've added a wave count to my game) it will seem like the player is moving really fast towards and just before the next wave the player will slow down and the next wave will start.
    So I've added a code, after completing a wave I've changed the background speed to -50 and it works. Now If I set the speed back to -1 at the start of a wave it looks really out of place so I am using this code on Update() inside the GameController.cs

    Code (CSharp):
    1. if(PlayerVariables.BGScrollingSpeed < bgScrollSpeed)
    2.         {
    3.             PlayerVariables.BGScrollingSpeed = Mathf.MoveTowards(PlayerVariables.BGScrollingSpeed, bgScrollSpeed, 1.0f * Time.deltaTime);
    4.             Debug.Log(PlayerVariables.BGScrollingSpeed);
    5.  
    6.         }
    PlayerVariables is just a new static class where i hold the BGScrollingSpeed to access it easily. and bgScrollSpeed is a public float in GameController.cs (and then on Start() i set the BGScrollSpeed to bgScrollSpeed)
    Now I get really weird behavior by this, at first it works, the BGScrollingSpeed slowly lowering towards -1 (the bgScrollSpeed I set in the edior) but when It gets to -10 the background start moving the other way on the Z axis. and when it finally reach it's initial value -1 once again the background start to move forward.

    Now I've tested many different values I also try to debug and the values seems fine but I don't know what's causing this.

    How it looks like :


    In the debug it shows the BGScrollignSpeed and the newPosition Float in BGScroller.cs
    float newPosition = Mathf.Repeat(Time.time * PlayerVariables.BGScrollingSpeed, tileSizedZ);
     
    Last edited: Feb 27, 2016
  36. Felix_M

    Felix_M

    Joined:
    Feb 28, 2016
    Posts:
    11
    IVE BEEN PISSED FOR HOURS BECAUSE EVERYTHING LOOKED FINE BUT THIS WAS IT

    I LOVE YOU AND GOOGLE.

    no caps lock, that pissed xD
     
  37. Felix_M

    Felix_M

    Joined:
    Feb 28, 2016
    Posts:
    11
    Position is giving a NullReference?

    Edit: So i figured out I was just getting ahead of myself, and soits a null reference because the reference isnt create until you serialize it? which creates a default value of 0?

    is this because the tutorial is being general? Not sure why the boundary isnt given specific values to begin with, or is a function to determine the screen boundaries, just within the code itself instead of having to serialize it then go into play+inspector?

    (to clarify, i have this part fixed, but not sure why we are doing the project in what seems like the hard way?)

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class Boundary
    6. {
    7.     public float xMin, xMax, zMin, zMax;
    8. }
    9.  
    10. public class PlayerController : MonoBehaviour {
    11.     public float speed;
    12.     private Rigidbody rb;
    13.     public Boundary boundary;
    14.     void Start ()
    15.     {  
    16.         rb = gameObject.GetComponent<Rigidbody>();
    17.     }
    18.     void FixedUpdate ()
    19.     {
    20.      
    21.         float moveHorizontal = Input.GetAxis ("Horizontal");
    22.         float moveVertical = Input.GetAxis ("Vertical");
    23.  
    24.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    25.         rb.velocity = movement * speed;
    26.  
    27.         Vector3 position = new Vector3 (Mathf.Clamp (rb.position.x, boundary.xMin, boundary.xMax),
    28.                 0.0f,
    29.                 Mathf.Clamp (rb.position.z, boundary.zMin, boundary.zMax)
    30.             );
    31.      
    32.         rb.position = position;
    33. }
    34. }
    35.  
    36.  
    37.  
     
    Last edited: Feb 28, 2016
  38. ShokeR0

    ShokeR0

    Joined:
    Feb 24, 2016
    Posts:
    112
    You must serialize the new class and set the values in the editor. And try to use a different name other than position
     
  39. Felix_M

    Felix_M

    Joined:
    Feb 28, 2016
    Posts:
    11
    But why only in the editor? Doesnt that make it impossible to make this with a flexible screen size?

    like instead of 600*900, to just fill up my phone instead?


    Im not really sure what the name of what I'm referring to is, so getting confused trying to read through documents on it other than resolutions.


    Im assuming I'd use the screen class to get the resolution of the device, then use that to set my screen width in the Player Settings?
     
  40. ShokeR0

    ShokeR0

    Joined:
    Feb 24, 2016
    Posts:
    112
    You are a bit confused. The class is not a pre built class by the unity engine. It is class that YOU BUILT. It does not do anythig beside hold some floats
     
  41. Felix_M

    Felix_M

    Joined:
    Feb 28, 2016
    Posts:
    11
    Sorry I'm not being clear. Haven't slept in so long. I understand I created the boundary class which is only used to restrict my movement.

    My question is hoe can I get the values for the boundary class automatically? Like if I made this for Android instead of pc standalone, how would I determine the boundarygiven the fact there are many screen sizes but I still want it full screen?
     
  42. ShokeR0

    ShokeR0

    Joined:
    Feb 24, 2016
    Posts:
    112
    You can check the PlayerSettings doc to see if you can return the reso of the screen and just assign them to the float directly in the code
     
    Felix_M likes this.
  43. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    Can anyone help me please? I am trying to stop enemies shooting when player is dead.
    Here is the code I use in GameControllerScript:
    Code (CSharp):
    1. private Component enemyFireScript;
    2.  
    3. void Start ()
    4. {
    5. enemyFireScript = GameObject.FindWithTag("Enemy").GetComponent<Done_WeaponController> ();
    6. }
    7.  
    8.     public void GameOver ()
    9.     {
    10.         gameOverText.text = "Game Over!";
    11.         gameOver = true;
    12.              enemyFireScript.enabled = false;
    13.     }
    And I have an error message: "unity engine component does not contain a definition for enabled"
    What is wrong?
     
  44. ShokeR0

    ShokeR0

    Joined:
    Feb 24, 2016
    Posts:
    112
    GameObject.FindWithTag("Enemy").GetComponent<Done_WeaponController> ().enabled = false; writing this from my phone so i might be wrong
     
  45. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    Shoker0, thank you for the answer. There is no the error message now, but frankly I did not get was wrong with my code.
    And what worse that this did not solve my main problem, the enemies are shooting anyway :/
    Any ideas how to stop them shooting?
     
  46. Felix_M

    Felix_M

    Joined:
    Feb 28, 2016
    Posts:
    11
    ahhhhhh ok thank you


    I didnt think to look in there and was only looking at the "screen" class which has all the code i need just no explanation. thank you so much man
     
  47. ShokeR0

    ShokeR0

    Joined:
    Feb 24, 2016
    Posts:
    112
    Are there any errors while you run the game and you can also check in the inspector if the script is enabled or not while the game is running in the editor
     
  48. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    58
    ShokeR0, thanx again, yes, when player is dead (gameover) I have this:"NullReferenceException: Object reference not set to an instance of an object
    Done_GameController.Update ()" ...I put this code to void Update { if (gameOver){ GameObject.FindWithTag...etc
     
    Last edited: Feb 29, 2016
  49. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    We made the decision after testing this project to use a fixed size for the game, as adding variable resolutions created a large amount of confusion to new users. Be aware that variable screen resolution impacts far more than justthe boundary object, which doesn't really need to be that exact for the game to work.
     
  50. Nameless Name

    Nameless Name

    Joined:
    Feb 29, 2016
    Posts:
    2
    Hello, I was wondering if someone could explain something to me with PlayerController scripting and its movement. Now below is the code I use for this tutorial .. it did not work when I first used it.. later I found out a possible problem I had with it when I did play to test my script. I had accidentally forgot the Rigidbody component and so I added it and still did not work.. later on I removed the Player object from the hierarchy completely and added Rigidbody and the PlayerController script again still did not work.. then I thought to myself Well maybe the script is wrong or if the Mesh Render" had something to do with it not working so. I removed everything once more the Player game object and script .. then I re-added the object but this time I used the movement script I had used from Rolling ball tutorial and it worked ... I checked the PlayerController script and the Rolling Ball movement script and they looked identical .. so I guess my question is .. does the order of which you do certain things effect how your script will perform with certain things such as movement and Rigidbody and if Mesh Render has anything to do with any of this at all?

    P.S. My fix for getting the player game object to move is a guess I am uncertain if that is how I got the Rolling Ball Script to work with this.. also when I orgionaly fixed my silly error in forgeting the Rigidbody component I had no errors in my code... from VStudio or from Unity.. if someone anyone can spot any errors in my coding below or explain to me as to why I could be having such an issue?
    Thank
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4.  
    5. public class PlayerController : MonoBehaviour {
    6.  
    7.     public float speed;
    8.  
    9.  
    10.     private Rigidbody rb;
    11.  
    12.  
    13.     void Start ()
    14.     {
    15.         rb = GetComponent<Rigidbody>();
    16.    
    17.     }
    18.     // movement script
    19.     void FixedUpdate()
    20.     {
    21.         float moveHorizontal = Input.GetAxis("Horizontal");
    22.         float moveVertical = Input.GetAxis("Vertical");
    23.  
    24.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    25.  
    26.         rb.AddForce(movement * speed);
    27.  
    28.  
    29.     }
    30.  
    31. }