Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Roll-a-Ball Tutorial Q&A [ARCHIVED]

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

Thread Status:
Not open for further replies.
  1. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    THIS THREAD IS CLOSED.

    The Roll-a-ball tutorial has been updated to Unity 5.
    Please see the new Q&A thread for comments.


    This is the official thread for discussion, issues and Q&A for the Roll-a-Ball project

    Please use this thread if you have any questions, issues or feedback on this project.

    Roll a Ball is a learning project on our Learn Site:
    http://unity3d.com/learn/tutorials/projects/roll-a-ball

    In your first foray into Unity development, create a simple rolling ball game that teaches you many of the principles of working with Game Objects, Components, Prefabs, Physics and Scripting.

    -

    Known Issues:

    • Please turn "annotations" on, as we try to annotate these videos if any issues are found. Many people turn annotations off, and miss these comments.
    • Unity 4.6 and higher: GUIText no longer has a shortcut prefab in the Create menu. Please create the GUIText element manually by creating a new empty GameObject and adding a GUIText component from the Component menu or the Add Component button on the GameObject.
    • Unity 5: You will not need to create directional lights for the "Main" and "Fill" lights. The new default lighting in Unity 5 makes this step redundant.
    • 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):
        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.
    Common Errors:
    • My GUIText is not visible on the screen
      • Check to make sure that the Transform Position x and y values are between 0 and 1.
      • In the Transform Position x value is either of the extremes of 0 or 1, make sure that the alignment is not pushing the text off of the screen.
      • Check that any "Parent" GameObject (like a holder game object) is set to "origin", or (0,0,0) in its Transform Position.
     
    Last edited: Apr 17, 2015
  2. Jeriko2k3

    Jeriko2k3

    Joined:
    Mar 18, 2015
    Posts:
    28
    On step 5 I had everthing working except the "collecting" part. Ball would just go through. On second play test getting error message:

    Assets/_Script/playerctrl.cs(23,31): error CS1061: Type `UnityEngine.Collider' does not contain a definition for `gameobject' and no extension method `gameobject' of type `UnityEngine.Collider' could be found (are you missing a using directive or an assembly reference?)

    Going to watch video again to double check myself any help would be......helpful.


    public class playerctrl : MonoBehaviour
    {
    public float speed;
    void FixedUpdate ()
    {
    float moveHorizontal = Input.GetAxis ("Horizontal");
    float moveVertical = Input.GetAxis ("Vertical");
    Vector3 movement = new Vector3(moveHorizontal, 0, moveVertical);
    GetComponent<Rigidbody>().AddForce(movement * speed * Time.deltaTime);
    }
    // Destroy everything that enters the trigger

    void OnTriggerEnter(Collider other)
    {
    if (other.gameObject.tag == "PickUp")

    {
    other.gameobject.SetActive(false);
    }
    }
    }
     
  3. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Jeriko2k3 likes this.
  4. Jeriko2k3

    Jeriko2k3

    Joined:
    Mar 18, 2015
    Posts:
    28
    thanks for the info, I literally, just figured it out about 4 minutes ago, found another issue (this due to one pickup object not being part of the prefab) fixed that and now I have a game!
     
  5. Ragequitass

    Ragequitass

    Joined:
    Mar 19, 2015
    Posts:
    1
    i cant finish the the first scrip,it said error after entering the unity. i copied everything in the tuturial,and it still says error
     
  6. KingfisherWyvernStudio

    KingfisherWyvernStudio

    Joined:
    Oct 5, 2011
    Posts:
    324
    Ragequitass, what is the errormessage you are receiving in the console? Without the error message it's hard to say what's wrong :)
     
  7. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    If you double click on the error in the console, and it should highlight the problem.

    If it's a scripting error, you will be taken to the line of code in the offending script. When you have a scripting error, you will not be able to enter play mode.

    If it's a runtime error, the offending fame object will be highlighted.

    This sounds like a scripting error? But I'm not sure from reading your post.

    Yes, please do post the error. To do so, click on the error in the console, and copy the text from the lower panel in the console and paste it here as part of a post.
     
  8. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yay! You made it! (Onwards to the next challenge!)
     
  9. Charlie.

    Charlie.

    Joined:
    Mar 19, 2015
    Posts:
    1
    Hi, I followed the tutorial up to the point where you are meant to see the options show up in unity to set the movement key. When I was finished with the script I pressed F8, there were no build errors but the moveHorizontal and moveVertical didn't show up in unity.

    Here's the script I used:
    using UnityEngine;
    using System.Collections;

    public class PlayerController : MonoBehaviour {
    void FixedUpdate ()
    {
    float moveHorizontal = Input.GetAxis ("Horizontal");
    float moveVertical = Input.GetAxis ("Vertical");

    Vector3 movement = new Vector3 (moveHorizontal, 0, moveVertical);

    GetComponent<Rigidbody> ().AddForce (movement);
    }
    }

    I tried using a random public float outside of FixedUpdate() and that showed up in unity but I can't get moveHorizontal and moveVertical to show up.
     
  10. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Your code is not formatted.

    Look here for more information:
    http://forum.unity3d.com/threads/using-code-tags-properly.143875/
     
  11. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You shouldn't see moveHorizontal and moveVertical in Unity. They are within the "scope" of FixedUpdate. They are created, live and die every frame within FixedUpdate, so there is no way to see, touch, talk to or interact with moveHorizontal and moveVertical directly.

    Did you want to? Or were you just curious? moveHorizontal and moveVertical should just "work" within FixedUpdate if they are properly written. moveHorizontal and moveVertical are simply containers to hold the float values that come from the Axes "Vertical" and "Horizontal". These are then used in the next line, to create 'movement'. Lastly, they are applied as part of "movement" to the ball through "AddForce". We shouldn't need to do anything with them at all.
     
  12. WardPeeters

    WardPeeters

    Joined:
    Mar 19, 2015
    Posts:
    25
    Hello,

    When I press ctrl + ' while selecting a word in my script it doesn't do anything.
    I'm using windows 8.1 and a qwerty keyboard.

    Thanks
     
  13. JohnnyBoy53

    JohnnyBoy53

    Joined:
    May 29, 2013
    Posts:
    1
    Edit: Nevermind, my fixedUpdate() function is supposed to be FixedUpdate()

    my script is attached to my ball object, but when I push arrows or wasd, the ball does not move. What could be wrong?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class playerController : MonoBehaviour {
    5.  
    6.     void fixedUpdate(){
    7.         float moveHorizontal = Input.GetAxis ("Horizontal");
    8.         float moveVertical = Input.GetAxis ("Vertical");
    9.  
    10.         Vector3 movement = new Vector3 (moveHorizontal,0.0f, moveVertical);
    11.  
    12.         GetComponent<Rigidbody>().AddForce(movement);
    13.     }
    14. }
    15.  
     
    Last edited: Mar 19, 2015
  14. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Humph! I'll look into that... It should work...
     
  15. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Case sensitivity!

    It should be FixedUpdate, not fixedUpdate!

    The convention goes:
    • variables: camelCase [lower case first letter, the rest Upper Case]
    • Functions: PascalCase [Upper Case First Letter, the rest Upper Case]
     
  16. Tibbers

    Tibbers

    Joined:
    Mar 20, 2015
    Posts:
    5
    Hi there I am not to sure what i am doing wring for the tutorial. I am just making the scrip for the movement of the player ball and i just cant get it to work.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour
    5. {
    6.     void FixedUpdate ()
    7.     {
    8.         float moveHorizontal = Input.GetAxis("Horizontal");
    9.         float moveVertical = Input.GetAxis("Vertical");
    10.        
    11.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    12.        
    13.         GetComponent<Rigidbody>().AddForce(movement);
    14.     }
    15. }
     
  17. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Not sure..,

    The code looks correct.

    Are there any errors? Is the script attached to the player? Is the player enabled and active? Do you have a rigidbody attached?
     
  18. Tibbers

    Tibbers

    Joined:
    Mar 20, 2015
    Posts:
    5
    Thank you i got it, This is my first time scripting and i made a few mistakes in unity :)
     
  19. Nexiom

    Nexiom

    Joined:
    Mar 23, 2015
    Posts:
    2
    hey,

    I don't get the text displayed. I am using Unity 5 and I used this manual:
    ' For those using the latest version of Unity and not finding the GUI Text:
    1) Add a new empty game object
    2) Choose "Add Component" on the right and go to "Rendering" and select "GUIText"

    I have typed some text in the 'text' box and the position is (0, 1, 0).
    What am I doing wrong?
     
  20. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yay! It's always a bit tough and frightening the first time in the pool. Glad you got it working. If there are any specific things that threw you off track, let me know, and I'll try to fix it. I'm hip-deep in updating this project to Unity 5, so now's the time to shout!
     
  21. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    The position seems correct. Check the alignment. At that position if you are aligned right, the text may be off the screen.

    If in doubt, set the transform's position to (0.5, 0.5, 0.0), which should put it in the middle of the screen.

    Try also changing the Color. Make sure the alpha is strong if not full (255??) and try a bright red, just to make sure it's not blending into the BG.

    If these don't work, post a screenshot here of your GUIText object's inspector.
     
  22. Nexiom

    Nexiom

    Joined:
    Mar 23, 2015
    Posts:
    2
    Strange... After trying several things several times it worked eventually!
    Thnx!
     
  23. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Ya. Sounded like a hiccup.
     
  24. Jeriko2k3

    Jeriko2k3

    Joined:
    Mar 18, 2015
    Posts:
    28
    I'm not sure what happened, I had everything working fine, had the points being counted (I have 13 cubes), when I went to make the "You Win", it all went to heck.

    Here are the error messages; After posting this I found that for some reason the script for the speed of the sphere is missing and not sure why or how that happened. If I am missing something in this code any help is appreciated. I will be backtracking in the meantime.

    Assets/_Script/playerctrl.cs(53,0): error CS1010: Newline in constant
    Assets/_Script/playerctrl.cs(53,0): error CS1525: Unexpected symbol `<internal>'
    Assets/_Script/playerctrl.cs(58,1): error CS8025: Parsing error

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class playerctrl : MonoBehaviour
    5. {
    6.     public float speed;
    7.     public GUIText countText;
    8.     public GUIText winText;
    9.     private int count;
    10.  
    11.     void Start ()
    12.     {
    13.  
    14.         count = 0;
    15.         SetCountText ();
    16.         winText.text = "";
    17.  
    18.     }
    19.  
    20.       void FixedUpdate ()
    21.     {
    22.         float moveHorizontal = Input.GetAxis ("Horizontal");
    23.         float moveVertical = Input.GetAxis ("Vertical");
    24.         Vector3 movement = new Vector3(moveHorizontal, 0, moveVertical);
    25.  
    26.         GetComponent<Rigidbody>().AddForce(movement * speed * Time.deltaTime);
    27.     }
    28.     // Destroy everything that enters the trigger
    29.      
    30.     void OnTriggerEnter(Collider other)
    31.     {
    32.         if (other.gameObject.tag == "PickUp")
    33.      
    34.         {  
    35.  
    36.             other.gameObject.SetActive(false);
    37.             count = count + 1;
    38.             SetCountText ();
    39.            
    40.  
    41.         }
    42.  
    43.     }
    44.     void SetCountText()
    45.  
    46.     {
    47.         countText.text = "Count: " + count.ToString ();
    48.         if(count >= 13)
    49.  
    50.         {
    51.  
    52.             winText.text = "YOU WIN!"'
    53.      
    54.        }
    55.  
    56.  
    57.    }
    58. }
     
  25. Socrates

    Socrates

    Joined:
    Mar 29, 2011
    Posts:
    787
    The last symbol on line 52 of your code is an apostrophe ' and not a semicolon ;. Change that and your errors should be taken care of.

    If you look at the two curly brackets after that line of code, you will see both are red. If you use MonoDevelop, they will be similarly marked. That's because the apostrophe makes MonoDevelop think they're all part of the literal.
     
    Jeriko2k3 likes this.
  26. Jeriko2k3

    Jeriko2k3

    Joined:
    Mar 18, 2015
    Posts:
    28
    I saw that and fixed it, but was having same issues as before; this is for those that make easy mistakes. Once corrected.....save the code and clear all errors before testing. sigh I wasted a day on this... Thanks Socrates. Well I guess it would only be a waste had I not learned anything.
     
  27. Jeriko2k3

    Jeriko2k3

    Joined:
    Mar 18, 2015
    Posts:
    28
    anyone else have an issue with centering the You Win Text. I deleted it a few times and ended up just doing it manually by putting Transform: position x 0, y .75, z 0 at .75;
    GUIText: Anchor Middle Center; Alignment Center and Pixel Offset X 600, y 0 . I could not get it to work like the video showed.
     
  28. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You need to be setting the x and y values, not the y and z values. z is depth away from camera. Also, the screen goes from (0,0) to (1,1), so the middle of the screen is (0.5, 0.5). Set the GUIText object's Transform.position to (0.5, 0.5, 0).

    The next is the pixel offset. This offsets the GUIText by the number of pixels, so if you are using a pixel offset of x = 600, y = 0, it won't be centered if the Transform.position is centered, it will be 600 pixels to the right of center. Set these to (0,0) and it will be centered.

    Now that the GUITex is centered, if you want it "up and out of the way" you need to push it up on the y-axis only! So, set the Transform.position to (0, 0.75, 0).
     
  29. gbBaku

    gbBaku

    Joined:
    Mar 24, 2015
    Posts:
    4
    I also have trouble making the guitext appear at all. I made an empty object, and made guitext it's component, and there on out I followed everything exactly as was in the video. I also tried making a text object, but even though that appeared, I could not refer it for the public variables of object player. I've uploaded a screenshot how my inspector looks.
    Setting the font size to 0 (as was the case in the video) didn't help. Messing with the colors didn't help. I'm aware that with the current positions, the text should appear in the middle of the screen.
    I appreciate any help.
     

    Attached Files:

  30. Patrel

    Patrel

    Joined:
    Mar 24, 2015
    Posts:
    6
    I am having trouble with picking up my pickups. Right now when I roll the ball to my pickups I roll through and the pickup is still there. Anyone know why that would be?
     
  31. gbBaku

    gbBaku

    Joined:
    Mar 24, 2015
    Posts:
    4
    Have you checked the "is trigger" checkbox in the box collider component?
     
  32. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Is the parent "Text" object at origin? This could be throwing off the GUIText object's transform. Make sure that the parent is at origin, and le t me know if that helps.
     
  33. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    If you are rolling through the cubes, you have either removed the default collider component (bad, but unlikely) or when checking your tags in OnTriggerEnter, the tags don't matcha, or the tag was not assigned.

    Check the video for these steps.

    You want to make sure the the spelling and capitalisation is the same for the tag comparison, and the tag created in the tag manager.

    If these are both identical ( and you can copy one and paste it on the other to be sure ), then you may have forgotten the step of assigning the tag. Make sure that the tag is created properly and spelled correctly in the tag manager and that the tag is assigned in the game object's inspector.
     
  34. gbBaku

    gbBaku

    Joined:
    Mar 24, 2015
    Posts:
    4
    The parent was not reset, thank you very much, resetting it did the trick. :)
    Could you please explain why was this a problem? So I won't run into it again. I know the basics of the basics of oop-ing (that probably helps both of us).
     
  35. Patrel

    Patrel

    Joined:
    Mar 24, 2015
    Posts:
    6
    Still not able to actually pick up my PickUp's. Attached is my PlayerController script. My PickUp does have Is Trigger checked. When I uncheck it, I bounce off it like a wall. When I check it then my ball rolls right through the PickUp. The Tag PickUp is assigend to the prefab and to all the PickUp's.

    My thoughts are that my PlayerController script must be off somehow. I do notice that with the version I am running I have GetComponent<Rigidbody>() instead of rigidbody. Below I will copy and paste my script so you do not need a copy of my script that is attached.

    using UnityEngine;
    using System.Collections;

    public class PlayerController : MonoBehaviour
    {
    public float speed;

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

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

    GetComponent<Rigidbody>().AddForce(movement * speed *Time.deltaTime);

    }
    void onTriggerEnter(Collider other)
    {
    if (other.gameObject.tag == "PickUp")
    {
    other.gameObject.SetActive(false);
    }
    }

    }
     

    Attached Files:

  36. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    A child's transform is always relative to the parent's transform, so the GUIText object will be offset by (0.5, 0.5, 0.0) from the parent, which, is it is (for example) (1.5, 2.5, 3.5) will put the GUIText object in world space at (2.0, 3.0, 3.5).
     
  37. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Your code is not formatted.

    Look here for more information:
    http://forum.unity3d.com/threads/using-code-tags-properly.143875/
     
  38. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Spelling and Capitalization!

    Code (CSharp):
    1. void onTriggerEnter(Collider other)
    ...should be:

    Code (CSharp):
    1. void OnTriggerEnter(Collider other)
    ... note the capital "O" in "On..."
     
  39. Patrel

    Patrel

    Joined:
    Mar 24, 2015
    Posts:
    6

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class PlayerController : MonoBehaviour
    6. {
    7.     public float speed;
    8.  
    9.     void FixedUpdate()
    10.     {
    11.         float moveHorizontal = Input.GetAxis ("Horizontal");
    12.         float moveVertical = Input.GetAxis("Vertical");
    13.  
    14.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    15.  
    16.         GetComponent<Rigidbody>().AddForce(movement * speed *Time.deltaTime);
    17.  
    18.     }
    19.     void onTriggerEnter(Collider other)
    20.     {
    21.         if (other.gameObject.tag == "PickUp")
    22.         {
    23.             other.gameObject.SetActive(false);
    24.         }
    25.     }
    26.  
    27. }
    28.  
     
  40. Patrel

    Patrel

    Joined:
    Mar 24, 2015
    Posts:
    6

    Problem is resolved now thanks to Adam. One letter I missed. Thought I was thorough, but I am not. Spent several days not being able to pick these things up. Learning is fun though. While going through these pickups it makes me think about games I play differently. Once I finish this lesson, I am going to go through it again and tweak some stuff. Practice mostly. Need to get ready for the next tutorial.
     
  41. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Great. Yes onTrigger should be OnTrigger...

    But that's a learning experience. When I first started coding games, I had a typo that held me up for weeks! Part of the learning process is learning where and how to look for potential problems.
     
  42. gbBaku

    gbBaku

    Joined:
    Mar 24, 2015
    Posts:
    4
    Thanks for the answer! :) Seems like a useful function
     
  43. JeffreyDriver

    JeffreyDriver

    Joined:
    Mar 26, 2014
    Posts:
    1
    Firstly, apologies if this has been answered elsewhere, but I looked and couldn't find anything.

    I was doing ok with the tutorial until I got to the part to make it count the pickups as you collect them. I touch them, they disappear, but the counter stubbornly remains at 0, showing 'Count: 0'. Here's my code:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerController : MonoBehaviour
    5. {
    6.     public float speed;
    7.     public GUIText countText;
    8.     private int count;
    9.  
    10.     void Start ()
    11.     {
    12.         count = 0;
    13.         SetCountText ();
    14.     }
    15.  
    16.     void FixedUpdate ()
    17.     {
    18.         float moveHorizontal = Input.GetAxis ("Horizontal");
    19.         float moveVertical = Input.GetAxis ("Vertical");
    20.  
    21.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    22.  
    23.         GetComponent<Rigidbody>().AddForce (movement * speed * Time.deltaTime);
    24.     }
    25.  
    26.         void OnTriggerEnter(Collider other)
    27.     {
    28.         if (other.gameObject.tag == "Pickup")
    29.         {
    30.             other.gameObject.SetActive (false);
    31.             count = count + 1;
    32.             SetCountText ();
    33.         }
    34.     }
    35.     void SetCountText () {
    36.         countText.text = "Count: " + count.ToString ();
    37.     }
    38. }
    I'm also receiving this error message:
    Any help gratefully appreciated.
     
  44. Giovanni_Kint

    Giovanni_Kint

    Joined:
    Mar 25, 2015
    Posts:
    1
    I dont know why i keep getting the error, but unity says ''the referenced script on this behaviour is missing''
    This is the script i am using:
    anyone got an idea what i did wrong?

    using UnityEngine;
    using System.Collections;

    public class PlayerController : MonoBehaviour
    {
    public float speed;

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

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

    GetComponent<Rigidbody>().AddForce(movement * speed *Time.deltaTime);

    }
     
  45. KingfisherWyvernStudio

    KingfisherWyvernStudio

    Joined:
    Oct 5, 2011
    Posts:
    324
    Have you renamed your script? Cause then it could give this message. Your console should give you a hint as to which gameobject this message is referring to. Check that game object to see if the script is still in it. If the gameobject doesn't have the script anymore (if I'm correct it will say it's missing the script in the inspector as well), link your script to the game object again and your problem will be solved.

    If you've made the script and only renamed it properly afterwards or named it in the MonoBehaviour afterwards:
    Code (CSharp):
    1. public class PlayerController : MonoBehaviour
    , you'll get this message. I've had the same problem. :)

    Also, for future references, it would be helpful to use the code format here on the forum like Adam Buckner suggested earlier:
    http://forum.unity3d.com/threads/using-code-tags-properly.143875/

    Happy coding!
     
  46. Socrates

    Socrates

    Joined:
    Mar 29, 2011
    Posts:
    787
    My first thought is to make sure that you have the correct thing assigned to countText in the Inspector. If not, your text won't update and you'd get an error saying there was no component.
     
  47. UniqueEdee

    UniqueEdee

    Joined:
    Mar 26, 2015
    Posts:
    2
    I have a question at this current moment that i cannot solve. When i create a gui text for my display text. No text appears on my scene screen and game screen even though i typed a word in the blank space of the text area. Please help.
     
  48. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    If there are errors in your console, then there could be some irregular behavior to your game.

    This particular error leads me to things that there is something wrong that's pretty bad.

    This error:
    MissingComponentException: There is no 'Rigidbody' attached to the "countText" game object, but a script is trying to access it.

    ... means just that: There is a script that is trying to find a rigidbody on the countText GameObject. This means you may have accidentally added a script you didn't want on to this GameObject, or have accidentally added a script to that GameObject that was meant to be somewhere else.

    Check that GameObject for a wild script that shouldn't be there.
     
  49. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Your code is not formatted correctly. Please read this page for more details:
    http://forum.unity3d.com/threads/using-code-tags-properly.143875/
     
  50. Daskalopoulos

    Daskalopoulos

    Joined:
    Mar 26, 2015
    Posts:
    1
    I have a problem , i'm at the number : 07 tutorial video for the "Roll a Ball" project , until now no problems , instead of the problem that i can't find the "GUI Text" in the "Create" or anywere in my engine .
    please help .
     
Thread Status:
Not open for further replies.