Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Official Roll-a-ball Tutorial Q&A

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

  1. Alexane22

    Alexane22

    Joined:
    Mar 6, 2019
    Posts:
    2
    I found, finally !If you have the same problem , just remove the "Player" on LateUpdate
     
  2. shane4roofie71

    shane4roofie71

    Joined:
    Feb 20, 2019
    Posts:
    5
    it worked thank you im new to coding what would you recommend to start on next and i got a new problem now and could you walk me throught what we just did more please so i can learn more
    upload_2019-3-8_20-30-44.png
     
  3. firstconversion

    firstconversion

    Joined:
    Mar 8, 2019
    Posts:
    3
    Im on the Moving the Player part of the tutorial and I have copied and pasted the script provided but it will not work. It gives me an error

    Assets\Scripts\PlayerController.cs(4,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'PlayerController'


    The script provided in the example:

    using UnityEngine;
    using System.Collections;

    public class PlayerController : MonoBehaviour {

    public float speed;

    private Rigidbody 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);
    }
    }
     
    boli_unity likes this.
  4. firstconversion

    firstconversion

    Joined:
    Mar 8, 2019
    Posts:
    3
    I see that there is another script called PlayerController in the completed game folder that you download as part of the tutorial. Please tell me its not that stupid
     
  5. firstconversion

    firstconversion

    Joined:
    Mar 8, 2019
    Posts:
    3
    Do you have any update on this issue? I am copying and pasting the exact code you provide in the tutorial

    Thank you!
     
    adel-akbi and m8 like this.
  6. m8

    m8

    Joined:
    Jul 5, 2015
    Posts:
    9
    Not taking to kindly to this favorite editor for writing scripts as --- It hasn't happened .. IDK So is there a way to find a nice editor for writing C# codes I find this here


    Notepad++ Installer 64-bit x64: Take this one if you have no idea which one you should take.​

    And that about says it all..it should not be difficult yet just jumping from the gui to the code window I got lost...

    I will probably be posting here again.. but if there is nobody posting between this and my next post ... I will just edit add.

    changed my preferences to --- notepad++ (is this a good idea) I was just drowned in intro to coding I thought it's just a ball... its just a plane.. but I guess I will continue on.

    went to the previous tutorial video where I now see a list of related tutorials like 11 of them OMG ok so ... what is the best path to use for these tutorials? what is like a list that goes in the logical growth of learning that is best????
     
    Last edited: Mar 27, 2019
  7. Zephyr_42

    Zephyr_42

    Joined:
    Mar 31, 2019
    Posts:
    1
    when I opened the tutorial there was an error message saying "the editor layout could not be fully loaded, this can happen when the layout contains EditorWindows not available in this project UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)"
    don't know if it's relevant or not but I'm using version 2018.3.11f1 Personal on a Mac.
     
  8. Terra1211

    Terra1211

    Joined:
    Apr 20, 2019
    Posts:
    1
    Hello,
    I want to make a roll-a-ball game with About 3 different Levels and i want to know how i get the game to go into the next Level after finishing the first with "You Win ". Do i just Need to make 3 different Scenes as Levels and then build them together into an exe file as the last toutorial says or how do i do that ?
     
  9. ItDaRapta

    ItDaRapta

    Joined:
    Jul 14, 2019
    Posts:
    2
    Hi, I need help with this project. when I do the collision detector for the cubes the ball is meant to collect, I use the onTriggerEntry function, which uses the word a 'other' lot. But when I go to run the program, the editor says that the word 'other' hasn't been defined. My code:
    Code (CSharp):
    1. OnTriggerEnter();
    2.     }          
    3.     void OnTriggerEnter(Collider other)
    4.         {
    5.             if(other.gameObject.CompareTag("Collect"))
    6.             {
    7.                 other.gameObject.SetActive(false);
    8.                    
    9.             }
    10.         }
     
  10. madjxatw

    madjxatw

    Joined:
    Jul 25, 2019
    Posts:
    1
    Hi,
    The first problem I encountered was that the color of the Ground was not blue but like purple, blue mixed with some other light colors. I just followed the tutorial video and set the color to RGB(0,32,64).
     
  11. StormingKiwi

    StormingKiwi

    Joined:
    Aug 3, 2019
    Posts:
    1
    Great tutorial. Completed it with no issues on the latest version of Unity.

    One issue though, at a few times in the lesson, reference is made to resources in the link below.... but there is no link below..
     
  12. nitrofurano

    nitrofurano

    Joined:
    Jun 7, 2019
    Posts:
    92
    a question about ./Assets/Scripts/PlayerController.cs : instead of using "other.gameObject.SetActive(false);" , how can we have those cubes having their opacity changed instead of disappearing, and then making them unable to increment "count" variable, since ".SetActive(false)" would not be used in this case?
     
  13. AndyTruman

    AndyTruman

    Joined:
    Aug 19, 2019
    Posts:
    13
    Thank you for sharing!
     
  14. Deleted User

    Deleted User

    Guest

    I have finished this roll a ball some time ago. Is there an easy way to add the code so that it can be used on mobile devices? is this difficult?
     
  15. jonasj_unity

    jonasj_unity

    Unity Technologies

    Joined:
    Jul 4, 2018
    Posts:
    20
    Hi, I don't think there is much to change. Basically everything will work, except for the ball movement.
    You can make a joystick:


    Or you can use accelerometer:
     
  16. Deleted User

    Deleted User

    Guest

    The keyboard moves it at a consistent speed. The touch screen which i copied from a youtube video, accelerates. That means once it moves, it takes time to slow down. They keyboard doesn't have this problem. So can you help? Please don't suggest joysticks. I just want to add code to make it mobile. Is this too difficult or impossible?
     
  17. unity_8ot4BpMIBi2_FA

    unity_8ot4BpMIBi2_FA

    Joined:
    Oct 11, 2019
    Posts:
    1
    After the Displaying the Score and Text tutorial, my PlayerController script is not working.
    The errors are:
    UnassignedReferenceException: The variable Player of CameraController has not been assigned.
    You probably need to assign the Player variable of the CameraController script in the inspector.
    CameraController.LateUpdate () (at Assets/Scripts/CameraController.cs:17)
    and
    The referenced script on this Behaviour (Game Object 'Player') is missing!
    The player does not move when I play.
     
  18. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    upload_2019-10-12_17-48-24.png
     
  19. jonasj_unity

    jonasj_unity

    Unity Technologies

    Joined:
    Jul 4, 2018
    Posts:
    20
    It is possible to make it move or stop at a consistent speed with joystick too :) Please tell me what inputs you would like to use for mobile and we can continue from there.
     
  20. Deleted User

    Deleted User

    Guest

    It's good that you are from the unity development team. I've been trying out your tutorials and this one is badly outdated. Can you update the tutorial in this link so I can apply it for the game? https://docs.unity3d.com/ScriptReference/Input.GetTouch.html. I find that I need to download an extra tool from the asset store to make my gettouch work. I look forward to

    1 - A proper update in the tutorial link
    2 - how i may apply the tutorial to the game - whether it's 2d or 3d.
     
  21. Deleted User

    Deleted User

    Guest

    @jonasj_unity,
    Thanks to you all, I have the code to insert this in the desktop and on the mobile. However, I wish to ask if we can create the installation for desktop and mobile at the same time. SEe the screenshot. I notice that I'm forced to switch platform and only then can the app work.
     

    Attached Files:

  22. Deleted User

    Deleted User

    Guest

    @jonasj_unity, everyone else,
    I am trying to program a level 2 in roll a ball. I want it so that the button not active. I've checked the internet for some code but none are working as expected. When I switch platform back to PC, i test by playing the game and the "pause" button is automatically active. I have removed the code and when I did, I noticed that pause doesn't come back anymore. So to me, it's an indication that the code is not suitable or wrong. I tried :

    GetComponent<Button>().interactable = false;

    and the button remains active. Let me know if a screenshot is required so whoever can understand this better.
     
  23. taralees

    taralees

    Joined:
    Aug 29, 2014
    Posts:
    40
    I am having a Heck of a time finding a Roll a ball with Mouse and Keyboard ... anyone have a C# Script for that ?


    REPLY
     
  24. Deleted User

    Deleted User

    Guest

    I'm not sure what link you got. Use this link : https://learn.unity.com/project/roll-a-ball-tutorial. The tutorial already gives enough script so that you can use it on your computer, regardless of whether it's win, mac or linux. If you can't find, it means you are not following the tutorial properly. And the code is all in C#. Start from tutorial 1. If you use the latest unity, you need to play around with the settings in inspector because many here are for the older unity versions.
     
  25. Deleted User

    Deleted User

    Guest

    Hi @jonasj_unity, some time ago, the link / solution you gave for the code worked on 3d. Whilst i have the code, I removed the post as the problem was solved. May I have the link again OR can you help with the 2d solution? As in what code do I need so that the app works on the smartphone? I've just completed the 2d ufo archived tutorial.
     
  26. taralees

    taralees

    Joined:
    Aug 29, 2014
    Posts:
    40
    Thank you for getting back to me ... But it still does not answer my Question ... Roll - a - Ball Tutorial does not Talk about Mouse control .. that is what I am looking for .. I would like to put Mouse controls in to Roll - A - Ball
     
  27. taralees

    taralees

    Joined:
    Aug 29, 2014
    Posts:
    40
    It does not teach you how to use Mouse with Roll - a - Ball
     
  28. taralees

    taralees

    Joined:
    Aug 29, 2014
    Posts:
    40
    That is what I would like to do is use Mouse and Key Board in Roll - A - Ball
     
  29. Deleted User

    Deleted User

    Guest

    @jonasj_unity, To the unity development team : We need your help to show the codes. Thanks.

    As far as I'm concerned, we use keyboard and mouse to enter the codes but movement is keyboard only.
     
  30. ihgumilar

    ihgumilar

    Joined:
    Dec 12, 2019
    Posts:
    2

    Hi I try to use the hotkey Ctrl + ' in windows but not working ? is it out of date ? I am using Visual Studio 2017 (Community) . I tried to use Ctrl + Alt + M, then Ctrl + H, it just showed up like the picture attached. Thanks in advanced for your help.

    Best,
    Ihshan
     

    Attached Files:

  31. rogue_moravec

    rogue_moravec

    Joined:
    Mar 6, 2020
    Posts:
    4
    I'm having an unusual problem with the ball movement. I've spent some time searching this forum, as well as other places, so I apologize if this has already been answered.

    I am roughly at the player movement portion.

    My ball responds to keyboard input, and goes in the right direction for the keys I use, but it responds differently to horizontal and vertical input. When I use the left and right keys, the ball responds as I expect. When I use the up or down keys, getting the ball to roll forward or backward, the ball will then not respond to the opposite direction key and continues to roll, without slowing down, off the plane.

    I had some issues with the editor responding with lag if too much memory was being used, so I tried it again with that reduced with no success. Also, the left and right respond appropriately, so it's not simply a matter of lag. I know the up and down keys are both working because I can start the ball rolling in either direction with those keys, it just won't subsequently respond to the opposite direction.

    No compiler errors, using version 2018.4.18f1.

    Thanks.

    -- Quick update --

    The WSAD keys are responding appropriately to forward and back motion, just not the up and down arrows. I also tried a different keyboard to make sure it wasn't a hardware fault of some kind. I am running the Unity app in an updated Debian stretch OS.
     
    Last edited: Mar 7, 2020
  32. Deleted User

    Deleted User

    Guest

    Hello @rogue_moravec,
    I had lots of other strange behaviour and wierd errors when i followed other tutorials in other websites. It's my suggestion that you avoid all Unity versions and try Unity LTS versions for stability purpose. Whilst LTS version are not guaranteed to be 100% perfect, non-LTS versions are much worse. In my case, I used 2018.4.7 LTS and the tutorial worked perfectly. There MIGHT be unknown errors that cause your problem. We won't know until you download an LTS and try. So please, if I were you, just migrate all your codes and file to LTS. It can save you lots of trouble. Whatever boundaries this tutorial had should work perfectly. I know as I've already completed this tutorial some time ago and everything worked perfectly. If you insist on using your existing unity you can. BUT - you should paste a screenshot and show what works / what doesn't. You didn't say if you already completed the tutorial or not. How many unity versions have you tried? Or is the 4.18 the only one you tried?
     
  33. rogue_moravec

    rogue_moravec

    Joined:
    Mar 6, 2020
    Posts:
    4
    Thanks for the recommendation! Though I was using an LTS version, I downloaded the previous one, 2018.4.37, and the up and down arrow key behaviour was correct.
     
  34. Deleted User

    Deleted User

    Guest

    You also better make sure you frequently check the unity LTS website for the latest version. As I said earlier, it is bug free. I am still in my udemy tutorials where every now and again, I find that certain things in an LTS version doesn't work until you upgrade to the latest LTS. So follow what I'm doing - just keep upgrading to the latest. And if it doesn't work, Go to help menu, send the development team a bug report. That's all U can do. I don't think it's difficult to find the LTS unity website.
     
  35. valarus

    valarus

    Joined:
    Apr 7, 2019
    Posts:
    399
    Did you adjust the speed ?
     
  36. agragaurav

    agragaurav

    Joined:
    May 9, 2020
    Posts:
    1
    I'm not able to get the ball to move at all. Neither with arrow keys, nor with WASD keys. The speed is set to 10, and the ball was not moving even before adding the speed variable.
     
  37. i2911

    i2911

    Joined:
    Jan 28, 2018
    Posts:
    1
    At time 2:38 of the video
    he is showing :
    Gizmos "Show Grid"
    but in my version
    Unity 2019.3.13f1 (64-bit)
    I do not have it.
    So I use
    "Toggle the visibility of the grid"
     

    Attached Files:

  38. holdrensilas2025

    holdrensilas2025

    Joined:
    May 29, 2020
    Posts:
    1
    I have a problem with the Player Controller script. Here's what it says
    Assets/Scripts/PlayerController.cs(49,6): error CS1513: } expected
    it also doesn't have the input in the player for the count text, and I'm not sure if this is normal but the canvas while not being on the camera is extremely big
     
  39. Mtester94

    Mtester94

    Joined:
    Jun 2, 2020
    Posts:
    1
    Hello, I have been having a problem with collecting the pickup's I followed the instructions in the video and the player just passes through the pickups. Any ideas what the problem is?

    upload_2020-6-2_16-31-58.png

    upload_2020-6-2_16-32-27.png
     
  40. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    You are missing a closing brace on line 25.
     
  41. unity_4r8qCokeAJvnDg

    unity_4r8qCokeAJvnDg

    Joined:
    Jun 11, 2020
    Posts:
    1
    Hello,
    I can't understand why my ball doesn't move with the keys on the keyboard. As soon as I start the game, it falls down. I'm on the 2 out of 8 Roll a Ball game (Unity 5 - Roll a Ball game - 2 of 8: Moving the Player)
    Thanks
     
  42. Lucifer656

    Lucifer656

    Joined:
    Jul 15, 2020
    Posts:
    7
    Just wanted to leave a thank you message. This was essentially my introduction to programming and game development, and I had a great time doing it. The guide was excellent, very informative and easy to follow.
     
  43. captainleemon

    captainleemon

    Joined:
    Aug 12, 2020
    Posts:
    1
    Hi! I'm new to Unity and need to build 3 levels for my Roll-a-ball game, but can't understand how. Could you maybe explain?
    I need to change scene after the player collects enough objects and the text "You win!" appears.
     
  44. PixilatedFox

    PixilatedFox

    Joined:
    Apr 5, 2021
    Posts:
    3
    I cant get the ball to move from section 2
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.ImputSystem;
    5. public class playercontrol : MonoBehaviour
    6. {
    7.  
    8.  
    9.     private Rigidbody rb;
    10.     private float movementX;
    11.     private float movementY;
    12.  
    13.     // Start is called before the first frame update
    14.     void Start()
    15.     {
    16.     rb = GetComponent<Rigidbody>();  
    17.     }
    18.  
    19.     void OnMove(InputValue movementValue)
    20.     {
    21.         Vector2 movementValue = movementValue.Get<Vector2>()
    22.  
    23.         movementX = movementVector.x;
    24.         movementY = movementVector.y;
    25.     }
    26.  
    27.     void FixtedUpdate
    28.     {
    29.         Vector3 movement = new Vector3(movementX, 0.0f, movementY);
    30.  
    31.  
    32.         rb.AddForce(movement);
    33.     }
    34. }
     
  45. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    You've missed the semicolon at the end of Line 21.
     
  46. HenryTurnerAudio

    HenryTurnerAudio

    Joined:
    Apr 7, 2021
    Posts:
    1
    Hi,

    Just started the roll-a-Ball tutorial, I am at the part where you have to install 'Input System' package, then apply it to the 'Player' Object as a component in order to generate movement. However even though the package is installed and verified according to the manager, the component does not show up in the components search list.

    I am using Unity 2020 version, on windows 10.
     

    Attached Files:

  47. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    Search for Player Input.
     
  48. PixilatedFox

    PixilatedFox

    Joined:
    Apr 5, 2021
    Posts:
    3
    Wow thank you :) I did not know people wold respond so fast!
    Thank you :cool:
     
  49. PixilatedFox

    PixilatedFox

    Joined:
    Apr 5, 2021
    Posts:
    3
    Now my project has two errors that say
    "error CS0234: The type or namespace name 'ImputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)"

    and

    "error CS0246: The type or namespace name 'InputValue' could not be found (are you missing a using directive or an assembly reference?)"

    and it wont let me play?
    does anyone now how to fix this :( I think it is mostly about the very top part.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.ImputSystem;
    5.  
    6. public class playercontrol : MonoBehaviour
    7. {
    8.  
    9.  
    10.     private Rigidbody rb;
    11.     private float movementX;
    12.     private float movementY;
    13.  
    14.     // Start is called before the first frame update
    15.     void Start()
    16.     {
    17.     rb = GetComponent<Rigidbody>();
    18.     }
    19.  
    20.     void OnMove(InputValue movementValue)
    21.     {
    22.         Vector2 movemenVector = movementValue.Get<Vector2>();
    23.  
    24.         movementX = movementVector.x;
    25.         movementY = movementVector.y;
    26.     }
    27.  
    28.     void FixtedUpdate()
    29.     {
    30.         Vector3 movement = new Vector3(movementX, 0.0f, movementY);
    31.  
    32.  
    33.         rb.AddForce(movement);
    34.     }
    35. }
     
    Last edited: Apr 9, 2021
  50. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    Line 4 should read: using UnityEngine.InputSystem;

    Line 22 should read: Vector2 movementVector = movementValue.Get<Vector2>();

    Line 28 should read: void FixedUpdate()