Search Unity

Official Roll-a-ball Tutorial Q&A

Discussion in 'Community Learning & Teaching' started by Adam-Buckner, Apr 17, 2015.

  1. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yes, at the time of the tutorial, the script editor that shipped with Unity was Monodevelop. You need to modify Visual Studio to do this. A quick google should tell you how.
     
  2. eoughphily

    eoughphily

    Joined:
    Oct 19, 2017
    Posts:
    2
    Hello, i'm completely new to programming and unity. I'm trying the roll a ball tutorial and am getting stuck where a lot of other people seem to be getting stuck...the ball doesn't move. I'm using the newest unity 2017.2.0f3, and I notice the tutorial calls for version 5, is there an incompatibility problem? I'm not getting any errors debugging the code, I've restarted the project multiple times and gone through the video multiple times and have crossed all my T's and dotted the i's as they would say. I've gone as far as copying and pasting the script from the tutorial and from multiple people on this thread just to get the ball to move with no luck. I have made sure that I set the speed. I'm getting to the point that I feel there is an incompatibility issue somewhere, especially since a lot of people are having the same problem. Got any ideas?
     
  3. eoughphily

    eoughphily

    Joined:
    Oct 19, 2017
    Posts:
    2
    Well, I didn't do anything different...I started over, this time going off of memory from the tutorial and now it seems to be working....I don't get it...lol
     
  4. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Could be a typo or capitalisation issue? This seems like a common place to get stuck, but I'm not sure what people are doing here because when I run it, or my staff runs it, it works - but we are less likely to make mistakes as we already know this content.

    If you do find any insight, let us know and we'll update the tutorial to help people over whatever bump this is.
     
  5. triangl

    triangl

    Joined:
    Oct 21, 2017
    Posts:
    2

    Attached Files:

  6. derlukas

    derlukas

    Joined:
    Oct 22, 2017
    Posts:
    2
    Hello guys! :)

    I just recently started studying with Unity. That's why I also looked at this tutorial "Roll a Ball" and, of course, also post-programmed.
    I'm just finished with the part that deals with moving the camera. And I have to say that everything really worked out well and is also very simple and understandable explained.
    But there is one thing I do not quite understand.
    In the CameraController script:

    Why does the offset have to be equal to the transform.position minus the player.transform.position? And why is exactly this offset then added again with the player.transform.position and assigned to the transform.position?

    Is there anybody who could explain this to me and help me?
     
  7. jasonf00

    jasonf00

    Joined:
    Oct 22, 2017
    Posts:
    1
    Hello, I have problem with tags like: MonoBehaviour, Rigidbody, Input, Vector3, they are not highlighted and of course ball is not moving. I just watched video 2 of 8. I'm sending photos of the code and editor.

    *I read that I have to set the speed of the ball, so it will move (I'm not sure if that information is true) but where can I find that option?

    Thanks!!!
    Screenshot (6).png

    Screenshot (5).png
     
  8. triangl

    triangl

    Joined:
    Oct 21, 2017
    Posts:
    2
    imho thats simple - 1st we get difference betweet camera coords and ball coord.

    then we just add that difference to current ball cords.

    offset (difference) = camera coords - ball coords;
    new camera coords = offseet + new ball coords;


    thats how we get smooth camera follow up without "jump" on 1st iteration
     
    derlukas likes this.
  9. derlukas

    derlukas

    Joined:
    Oct 22, 2017
    Posts:
    2
    Thank you very much! You helped me a lot! :)
     
  10. Gabzilla72

    Gabzilla72

    Joined:
    Oct 24, 2017
    Posts:
    2
    please help a newbie, what have i done wrong here:
    upload_2017-10-24_0-24-19.png
     
  11. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    line 21 should be
    rb.AddForce(movement);
    not
    rb.AddForce = (movement);
     
    Gabzilla72 likes this.
  12. Gabzilla72

    Gabzilla72

    Joined:
    Oct 24, 2017
    Posts:
    2
    Thanks, that was really baking my noodle!
     
  13. mcgrasshopper

    mcgrasshopper

    Joined:
    Oct 25, 2017
    Posts:
    2
    So I just finished the project and I built it but instead of showing "You Win!" it just shows "Win Text" for the whole game and doesn't change once I've collected them all. It does this in the example project that I downloaded that goes with the tutorial as well. I'm on a mac I don't know why it's doing this. Any help would be great.
     
  14. Invisible-Eyes

    Invisible-Eyes

    Joined:
    Nov 27, 2016
    Posts:
    22
    Where did you specify the "You Win" , did you use the text script component in the Inspector window?
     
  15. mcgrasshopper

    mcgrasshopper

    Joined:
    Oct 25, 2017
    Posts:
    2
    Sure did, I followed the instructions in the videos exactly. When I do a play test it runs like it's supposed to but when I build and then run it from the folder it doesn't work right.
     
  16. Programmer128

    Programmer128

    Joined:
    Oct 25, 2017
    Posts:
    1
    I can't figure out how to move! I typed in the code but speed doesn't show up! This is my code...
    using UnityEngine;
    public class PlayerController : MonoBehaviour
    {
    public float speed;
    private Rigidbody rb;
    public PlayerController()
    {
    }
    public PlayerController(float speed, Rigidbody rb)
    {
    this.speed = speed;
    this.rb = rb;
    }
    void Start()
    {
    rb = GetComponent<Rigidbody>();
    }
    void FixedUpdate()
    {
    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");
    Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    rb.AddForce(movement * speed);
    }
    }
     
  17. rhaithe

    rhaithe

    Joined:
    Oct 27, 2017
    Posts:
    4
    I just downloaded Unity a few days ago and was struggling to get a handle on the basics. This tutorial was a lifesaver! Thank you so much. The instructions were clear and concise. Once I had completed the tutorial, I really felt like I understood how things worked. I might have given up on Unity had I not discovered this tutorial. Now I am whizzing through the others and they are making sense now that I feel a bit more grounded in the basics. Thanks again for making my life so much easier!
     
    MartinPowell2001 and organicvr like this.
  18. gaurides

    gaurides

    Joined:
    Oct 12, 2017
    Posts:
    2
    What's the default key on Windows to make the ball move?
    I can not move the ball. I am on tutorial 2, the script looks fine, no errors on unity screen. I can go to play mode, but i can't move the ball. I tried the mouse and the arrow keys on my keyboard.
     
  19. gaurides

    gaurides

    Joined:
    Oct 12, 2017
    Posts:
    2
    Oh ok. figured it. I added speed setting and it was initialised to 0. Otherwise I can use the arrow keys.
     
  20. Wolokos

    Wolokos

    Joined:
    Apr 7, 2017
    Posts:
    1
    So my game works quite well when I "play" it in unity, but then when I build the game, the sphere simply passes through the Pick Ups. That is to say, the Pick Ups don't disappear and the counter doesn't increase. I don't understand why....
     
    ieglandDCS likes this.
  21. Mukulgupta

    Mukulgupta

    Joined:
    Nov 7, 2017
    Posts:
    2
    in the videos you are using mac and i am using windows 10 so will there be any change in coding because there always comes a error and when i solve it the place dissapear where we wrote speed
     
  22. Mukulgupta

    Mukulgupta

    Joined:
    Nov 7, 2017
    Posts:
    2
    please reply my question
     
  23. nuriemmi

    nuriemmi

    Joined:
    Nov 11, 2017
    Posts:
    1
    windows ok, UWP ok. but android, I see only ball and ground. how will move ball on Android? because you know there is no direction button or mouse. :)
     
  24. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    Please post the error you are seeing
     
  25. Seanie987

    Seanie987

    Joined:
    Sep 2, 2017
    Posts:
    1
    Don't know if i will get a awnser but anyway in lesson 7, I get a error
    I don't understand what it means. I'm using version 5.6.2f1. Here is my code:
    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine.UI;
    3. using UnityEngine;
    4.  
    5. public class PlayerController : MonoBehaviour {
    6.  
    7.     private Rigidbody rb;
    8.     private int count;
    9.  
    10.     public float speed;
    11.     public Texture countText;
    12.  
    13.     void Start ()
    14.     {
    15.         rb = GetComponent<Rigidbody>();
    16.         count = 0;
    17.         SetCountText ();
    18.  
    19.     }
    20.  
    21.     void FixedUpdate ()
    22.     {
    23.         float moveHorizontal = Input.GetAxis ("Horizontal");
    24.         float moveVertical = Input.GetAxis ("Vertical");
    25.  
    26.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    27.  
    28.         rb.AddForce (movement * speed);
    29.     }
    30.     void OnTriggerEnter(Collider other)
    31.     {
    32.         if (other.gameObject.CompareTag ("Pick Up"))
    33.         {
    34.             other.gameObject.SetActive (false);
    35.             count = count + 1;
    36.             SetCountText ();
    37.         }
    38.     }
    39.  
    40.     void SetCountText ()
    41.     {
    42.         countText.text = "Count: " + count.ToString ();
    43.     }
    44. }
     
  26. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    At line 11 you have: public Texture countText;
    It should be: public Text countText;
     
  27. juddk1986

    juddk1986

    Joined:
    Nov 18, 2017
    Posts:
    5
    I've followed the tutorial 100% and the game is running fine, but when I go to build I get this...

    https://imgur.com/EKabQaf

    What is stopping it from building?
     
  28. saudy999

    saudy999

    Joined:
    Nov 20, 2017
    Posts:
    1
    Hi Friends
    The problem is that the Ball still NOT moving I used the keys (W,A,S,D). I am a Mac user.
    This is the scripts
    Screen Shot 2017-11-19 at 8.48.01 PM.png
     
  29. juddk1986

    juddk1986

    Joined:
    Nov 18, 2017
    Posts:
    5
    Um maybe where you have MoveHorizontal and MoveVertical don't use capital 'M' just use lower case. and put a space after rb.AddForce before the (

    Edit, have you tried the arrow keys?
     
  30. up2empyrean

    up2empyrean

    Joined:
    Nov 20, 2017
    Posts:
    2
    Hello everybody!
    I am new to Unity and of course i m having a problem here. Please help a newbie.
    In the tutorial video the instructor talks about creating the reference by dragging the main camera to the player slot in the camera control component.
    But I don't see the player slot in the camera control component.
    Here are the screenshots:
    屏幕快照 2017-11-20 下午4.32.36.png
    屏幕快照 2017-11-20 下午4.35.01.png
    Thanks.

    Edit, never mind, i've found where the problem is, i miss-spelled the "control" in "public class camera control". Spelling every word correct is not easy for a non native speaker.
    Anyway, i feel happy when i correct the mistake and my project works as the tutorial shows.
     
    Last edited: Nov 20, 2017
  31. Bevan_Chen

    Bevan_Chen

    Joined:
    Nov 21, 2017
    Posts:
    5
    dear Adam-Buckner,i'm a chinese developer,i want to learn this Tutorials, and try a lot mothed to watch the Tutorials's video, but i can't watch the video, don't kown what's the matter. is it forbiden in china or another problem? can you help get the Tutorials's video? Thank your very much!
     
  32. Bevan_Chen

    Bevan_Chen

    Joined:
    Nov 21, 2017
    Posts:
    5
    i don't think the video don't support Firefox,i cant watch with chrome and QQ Browser too. mybe dont support China?
     
  33. up2empyrean

    up2empyrean

    Joined:
    Nov 20, 2017
    Posts:
    2
    The tutorial video is actually "quoted" from youtube, that's why you cant watch them from mainland china.
    Find a vpn that can help you access youtube, then you should be able to watch those videos.
     
  34. Bevan_Chen

    Bevan_Chen

    Joined:
    Nov 21, 2017
    Posts:
    5
    Thank you,let me try
     
  35. Bevan_Chen

    Bevan_Chen

    Joined:
    Nov 21, 2017
    Posts:
    5
    Can you recommend a VPN to me?
     
  36. Bevan_Chen

    Bevan_Chen

    Joined:
    Nov 21, 2017
    Posts:
    5
    if i can visit youtube,can i download the tutorial video from youtube?
     
  37. mc3

    mc3

    Joined:
    Mar 27, 2016
    Posts:
    19
    I have been looking at a few ways to extend the tutorial:
    • I would like to make the player bounce off the pickup items. It would still pick them up, it would just change the players direction.
    • Create a small explosion when the item is picked up.
    • Change the square to spin locked on the y axis.
    If anyone can help give me some feedback on those, I am going to work on that this morning.
     
  38. JLowther

    JLowther

    Joined:
    Dec 1, 2017
    Posts:
    1
    Just wanted to say that this is a phenomenal tutorial!

    Thanks so much for making it! :)
     
  39. matthewhullejv

    matthewhullejv

    Joined:
    Dec 3, 2017
    Posts:
    1
    I have an issue with roll a ball where if I set the input for the Horizontal and Vertical acces to keyboard the ball will move as though I am preessing the up and left key even though Im not.
     
  40. BrewNCode

    BrewNCode

    Joined:
    Feb 17, 2017
    Posts:
    372
    Already built the project, I have a question for the experienced:
    How can I procedurally generate the cubes in the circle, instead of setting them in the ground?

    thank you very much for your concern.
     
  41. thegreatkoala

    thegreatkoala

    Joined:
    Jun 30, 2017
    Posts:
    11
    Hi,

    I've finished the tutorial and am playing around a little. I've renamed "Count" to "Score" throughout the code.
    I'm trying to cut down on how much scripting gets done so rather than having "SetScoreText()" in every IF statement, am I better off moving it to FixedUpdate() like below?

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

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

    rb.AddForce (movement * speed);
    SetScoreText();
    OpenDoor1();
    //Debug.Log (score);
    }

    void OnTriggerEnter(Collider other)
    {

    if (other.gameObject.CompareTag("Pickup10"))
    {
    other.gameObject.SetActive (false);
    score = score + 10;
    //SetScoreText();
    }
    else
    if (other.gameObject.CompareTag("Pickup50"))
    {
    other.gameObject.SetActive (false);
    score = score + 50;
    //SetScoreText();
    }
    else
    if (other.gameObject.CompareTag("Pickup100"))
    {
    other.gameObject.SetActive (false);
    score = score + 100;
    //SetScoreText();
    }
     
  42. ranuathomas

    ranuathomas

    Joined:
    Dec 12, 2017
    Posts:
    1
    For some reason, I can not get to the proper coding software that is suppose to pop up according to the software.
     
  43. Deleted User

    Deleted User

    Guest

    In Unity, go to Edit/Preferences... In the window that pops up, go to the "External Tools" tab and make sure that "Internal" is selected. If not, select "MonoDevelop (built in)" in the drop down menu.
     
  44. harsha9064

    harsha9064

    Joined:
    Dec 13, 2017
    Posts:
    1
    I have error in Roll a Ball game
    i.e.,Argument exception:Input Axis is not setup
    can you help to resolve this?
     
  45. Deleted User

    Deleted User

    Guest

    Check all the lines that contain

    Code (CSharp):
    1. Input.GetAxis ("Name of the axis")
    in your script, you made a typo when you wrote the name of the axis.
     
    Last edited by a moderator: Dec 13, 2017
  46. kavehnwc

    kavehnwc

    Joined:
    Dec 16, 2017
    Posts:
    1
    When the player collides with the cubes it does not make it disappear or add to the counter. Here is my code.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. public class PlayerController : MonoBehaviour
    7. {
    8.  
    9.     public float speed;
    10.     public Text countText;
    11.     public Text winText;
    12.  
    13.     private Rigidbody rb;
    14.     private int count;
    15.  
    16.     void Start()
    17.     {
    18.         rb = GetComponent<Rigidbody>();
    19.         count = 0;
    20.         SetCountText();
    21.         winText.text = "";
    22.     }
    23.  
    24.     void FixedUpdate()
    25.     {
    26.         float moveHorizontal = Input.GetAxis("Horizontal");
    27.         float moveVertical = Input.GetAxis("Vertical");
    28.  
    29.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    30.  
    31.         rb.AddForce(movement * speed);
    32.     }
    33.  
    34.     void OnTriggerEnter(Collider other)
    35.     {
    36.         if (other.gameObject.CompareTag("Pick Up"))
    37.         {
    38.             other.gameObject.SetActive(false);
    39.             count = count + 1;
    40.             SetCountText();
    41.         }
    42.     }
    43.  
    44.     void SetCountText()
    45.     {
    46.         countText.text = "Count: " + count.ToString();
    47.         if (count >= 6)
    48.         {
    49.             winText.text = "You Win";
    50.         }
    51.     }
    52. }
    53.  
     
  47. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    Please confirm the tag on your cube object is set to
    Pick Up

    That is capital P and U, with a space between
     
  48. ketchupinho

    ketchupinho

    Joined:
    Jan 14, 2017
    Posts:
    4
    Hey, I'm having issues with the Movement part of the tutorial.

    I have no control over the ball. When I go to play mode, nothing happens. Checked the code several times for typos, it seems ok.

    Here's the code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerController : MonoBehaviour {
    6.  
    7.     private Rigidbody rb;
    8.     public float speed;
    9.  
    10.     void start ()
    11.     {
    12.         rb = GetComponent<Rigidbody>();
    13.  
    14.     }
    15.     void FixedUpdate ()
    16.     {
    17.         float moveHorizontal = Input.GetAxis ("Horizontal");
    18.         float moveVertical = Input.GetAxis ("Vertical");
    19.  
    20.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    21.  
    22.         rb.AddForce (movement * speed);
    23.     }
    24. }
    25.  

    This is my third attempt at learning unity, last two ended the same way - I copied the script 1:1 and it didn't work. I was hoping things would be different following an official tutorial this time around. This is so frustrating I'm close to breaking my keyboard in half...

    EDIT: I'm using Unity 5.5.0f3
     
  49. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    Line 10, capitalize method name "start"
    is: void start ()
    should be: void Start ()
     
  50. ketchupinho

    ketchupinho

    Joined:
    Jan 14, 2017
    Posts:
    4
    Thank you, I'll watch out for capitalization from now on. That was kinda embarrassing but lesson learned.