Search Unity

Official Roll-a-ball Tutorial Q&A

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

  1. Chessnutter

    Chessnutter

    Joined:
    Dec 21, 2017
    Posts:
    1
    Great tutorial!

    I expanded the game into a 3d maze sort of game, and the biggest problem I am having is that the player can move the ball while the ball is falling down. I want it so that the player can only move the ball when the ball is touching a plane or 3d object.


    Any help would be greatly appreciated!
    Thanks!
     
    Last edited: Dec 21, 2017
  2. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Could this be causing my issue as mentioned here;

    https://forum.unity.com/threads/roll-a-ball-tutorial-movement-issue.503382/#post-3282825

    I have just upgraded to v 2017 v3 and upgraded the project. Do I need to change the script to eliminate the issue I am having of the ball rising as described in the above topic?

    Many thanks.
     
  3. augustersej123

    augustersej123

    Joined:
    Dec 24, 2017
    Posts:
    1
    why won't this work? Please help me
    this is just to make the ball roll



    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Player : 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, 0f, moveVertical);

    rb.AddForce (movement);


    }
    }
     
  4. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    Please see post 1600, the last post of the previous page
     
  5. stafko

    stafko

    Joined:
    Dec 25, 2017
    Posts:
    2
    I got a problem. Can't get my ball to move. Can you somehow help me, please


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerController : MonoBehaviour {
    6.  
    7.     public float speed;
    8.  
    9.     private Rigidbody rb;
    10.  
    11.     void start ()
    12.     {
    13.         rb = GetComponent<Rigidbody>();
    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.         rb.AddForce (movement * speed);
    24.  
    25.    
    26.         }
    27.  
    28. }
    29.  
     
  6. Deleted User

    Deleted User

    Guest

    You must pay attention when you write code, code is CASE SENSITIVE.

    Code (CSharp):
    1. void start ()
    does not exist; it's not the same thing as

    Code (CSharp):
    1. void Start ()
    Merry Christmas anyway! :)
     
    stafko likes this.
  7. stafko

    stafko

    Joined:
    Dec 25, 2017
    Posts:
    2
    THANKS a lot, man!
     
  8. EmberVideoGames

    EmberVideoGames

    Joined:
    Dec 28, 2017
    Posts:
    1
    On the second video after writing the script the way you say to it tells me NullReferenceException
     
  9. danna1234

    danna1234

    Joined:
    Dec 29, 2017
    Posts:
    1
    I'm starting the project and when I changed the lighting rotation in Y to 60 the way it's said on the tutorial it appeared at the back of the sphere instead of appearing at the front like it is in the video. The only way in which it looks like in the video is if I change it to -60 which I don't think is ok. How can I change the view so I can look at everything the way it's on the video?
     
  10. Deleted User

    Deleted User

    Guest

    I too am struggling with step 2 getting the ball to move. I've read through many of the answers previously, but none seem to match as a solution when I check my code. I don't see anything different in my code than from the tutorial. I tried several speeds, and both the WASD keys and arrow keys. I'm on a Mac and my code is:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    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);
    }

    }

    What am I missing?
     
  11. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    Checking post 1570 from the previous page, is it possible your speed value is 0?
    You could (just for one time) change
    from: rb.AddForce (movement * speed);
    to: rb.AddForce (movement * 5.0f);

    You could add a debug line to write to console:
    Debug.Log("PlayerController.FixedUpdate: speed="+ speed);
    This would also confirm your method "FixedUpdate" is getting executed

    Confirm there are no compile or runtime error messages and the console log is not reporting errors

    Confirm you have attached your working script (not the script from the "_Completed_Game" directory)
     
  12. Baal_9

    Baal_9

    Joined:
    Dec 31, 2017
    Posts:
    1
    Hey, i just downloaded yesterday and am using Unity for the first time (first hour): why does Unity close down ALL the time???

    Every single tutorial asks to save/don't save, then keep/forget and the Unity just closes. Even trying to load the next tutorial shuts it down and i have to open from the start menu...... Trying to follow the roll a ball tutorial and start new project but it shuts down without making a new file????? It finally made one after i selected keep instead of forget, but it still closes the program and does nothing (says task manager)

    Both 'keep' and 'forget' ALWAYS shut down Unity; am i the only one having these issues? Please help this is a terrible intro :mad: Also, tutorial projects have stopped downloading after i tried to open Roll-a-Ball (while they were downloading) and Unity did the aforementioned closing down issue..
     
  13. Deleted User

    Deleted User

    Guest

     
  14. Deleted User

    Deleted User

    Guest

    I checked my speed--was set to 10, but tried this method anyway. Tried the debug and then got both a "all must be compiled before entering play mode error" as well as error CS1525: Unexpected symbol 'Debug'. Any suggestions? I still don't see anything in my syntax or code. Thanks for your help!
     
  15. deadbrokoli

    deadbrokoli

    Joined:
    Dec 31, 2017
    Posts:
    1


    I am on step 2/8 and my script is not moving the ball.
    here is the script:

    using UnityEngine;
    using System.Collections;

    public class playerContol : MonoBehaviour {

    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);
    }
    }





    could someone help debug or post the working script on this step?
     
  16. AlecJames

    AlecJames

    Joined:
    Dec 31, 2017
    Posts:
    1
    @deadbrokoli The method name should be FixedUpdate with a capital 'F', not fixedUpdate.
     
  17. BoxhoundTKO

    BoxhoundTKO

    Joined:
    Dec 31, 2017
    Posts:
    2
    I am having trouble moving the ball even though I have checked my code about 4 times, line by line, twice which I actually did find an error, but now I am just frustrated at what else I could have done wrong. I am using the latest version of Unity Personal, and my compiler is the built-in one and not Visual Studios. I also checked my inputs to see if my arrow keys and 'WASD' were default and they were. I am completely stuck, please help.

    Here are the components for my sphere "https://imgur.com/a/Xz7kr"

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

    Deleted User

    Guest

    You must make sure there are no typos in your script. I've at least spotted one: it's FixedUpdate () not FixedUpdated ().

    Happy new year anyway!
     
    BoxhoundTKO likes this.
  19. Deleted User

    Deleted User

    Guest

    *rb.AddForce (movement * speed);

    have you tried that yet?
     
  20. BoxhoundTKO

    BoxhoundTKO

    Joined:
    Dec 31, 2017
    Posts:
    2
    Thank You, I finally feel relieved! That 1 little typo fixed my issue and now I can move my ball all over the plane. Happy new year!
     
  21. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    I'm not on a Mac, and my version of Unity is old, but I dont think Debug.Log should cause an error.
    It is one of the most important tools in your software development kit.
    Hopefully someone else can confirm this is available to you on the Mac.

    1) Exit your Unity session and restart it. Some people have found this clears up their problems,
    and it is an easy thing to do.

    2) Please double check the Debug.Log statement. If need be, modify it to:
    Debug.Log("PlayerController.FixedUpdate Hello world");

    3) Please post your code (using code blocks to make it more readable).

    4) Confirm you have attached your working script (not the script from the "_Completed_Game" directory)
    in your inspector and the code you are modifying is in your working directory (not the "_Completed_Game" directory)
    Move or Delete the "_Completed_Game" directory to make sure there is no accidental confusion.

    5) Comment out the "Debug.Log" statement and confirm there are no compile or runtime error messages and the console log is not reporting errors in your working code.
    You must be sure you are compiling and running error free code code, and it is the code you expect (ie, in your working directory).

    good luck nekune_913
     
  22. Deleted User

    Deleted User

    Guest

     
  23. Deleted User

    Deleted User

    Guest

    Got it working with that advice! Thank you!
     
  24. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144
    Excellent!
    As a help for others who are have similar problems as they do the tutorial, could you provide some details on how you finally resolved your problem?
     
  25. jconway2002

    jconway2002

    Joined:
    Jan 10, 2018
    Posts:
    1
    One small issue:

    The "You Win" text is slightly above the player when I play the game in the editor, but once I build the game it appears directly on top of the player. I have tried saving the scene and rebuilding but no luck. Any ideas what I am doing wrong?
     
  26. EthanRawstron

    EthanRawstron

    Joined:
    Jan 11, 2018
    Posts:
    1
    I just finished the camera movement tutorial but the Main camera is stuck inside my player.
     
  27. Dracarnion

    Dracarnion

    Joined:
    Jan 11, 2018
    Posts:
    1
    For those that couldn't get the ball to move, delete the PlayerController script and click on the Ball. In the Inspector tab, Click add component and click "Add Script" at the bottom. This will create the script and associate it with the object. If you don't do it this way, you have to create the script and associate it with the Player object as a separate step.
     
  28. bschiavina

    bschiavina

    Joined:
    Jan 12, 2018
    Posts:
    2
    Hi everybody, I am struggling with this code... I checked it so many times but still I cannot see my mistake.

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

    bschiavina

    Joined:
    Jan 12, 2018
    Posts:
    2
  30. mateusmelo500

    mateusmelo500

    Joined:
    Jan 19, 2018
    Posts:
    1
    Hi

    Is there a text version of this Unity tutorial instead of a video version? If so, I would appreciate using a text tutorial rather than a video one. Nothing wrong about the video tutorial, it's just my preference haha

    Thanks in advance
     
  31. Vivekveri

    Vivekveri

    Joined:
    May 20, 2017
    Posts:
    2
    Hi ,

    In the 3rd Tutorial Video, moving the player using Scripting, is there any specific reason why input.get axis was used?
    why didn't we use Input.anyKey? Doesn't both perform the same operation?
     
  32. GotUhaha

    GotUhaha

    Joined:
    Jan 23, 2018
    Posts:
    1
    Hello!
    The video doesn't work in my computer, so I can't begin to study the unity. How to solve this. Or can I download it by some means?
    Thank you for reading.
     
  33. MartinPowell2001

    MartinPowell2001

    Joined:
    Jan 24, 2018
    Posts:
    5
    Thanks for this tutorial, as a noob Unity user it was a great introduction.
    I have a issue though. everything works fine in the unity editor...

    The ball rolls, I can collect the pickups, and counters work etc great.
    But when I build the project as a stand alone application.
    I can run it and the ball moves, but it wont pick up the cubes, it just rolls straight through them!

    Any ideas as to why this is happening please?

    Thanks
     
  34. LolaSin

    LolaSin

    Joined:
    Jan 25, 2018
    Posts:
    4
    Hi, I have a problem with this tutorial. I see the "you win" message in the game mode but when I export the game (windows) I can't see it when the game is over.
    Can anyone help? thanks
     

    Attached Files:

  35. MartinPowell2001

    MartinPowell2001

    Joined:
    Jan 24, 2018
    Posts:
    5
    I have compiled this as a Windows application and have tried many times. it only fails when i build the final solution. When running in the Unity IDE at all works fine!

    It's driving me mad, I do not know what I am doing wrong.
     
  36. MartinPowell2001

    MartinPowell2001

    Joined:
    Jan 24, 2018
    Posts:
    5
    Sounds similar to my issue in that what happens in the editor is not what happens when your build a full runtime version of the same code.

    I've not seen your exact issue, but I'm guessing they have similar root cause reasons. Just need someone with more experience to comment.
     
  37. MartinPowell2001

    MartinPowell2001

    Joined:
    Jan 24, 2018
    Posts:
    5
    Did you ever get an answer to this issue as I'm having the exact same problem.
     
  38. LolaSin

    LolaSin

    Joined:
    Jan 25, 2018
    Posts:
    4
    no, not yet
     
  39. MartinPowell2001

    MartinPowell2001

    Joined:
    Jan 24, 2018
    Posts:
    5

    OK, I think I have sussed this out.
    It was not clear n the video, but you have to also use the "Pick Up" tag on the player object as well.

    I made just this change and rebuild the stand alone version of the game and "Bingo!" I can pickup the cubes! :)

    Onwards and upwards!
     
  40. LolaSin

    LolaSin

    Joined:
    Jan 25, 2018
    Posts:
    4
    cool :)
    for me, i did manage to pick up the cubes. my problem was that at the end of the game i didn't get the 'you win' message on the screen. i think the problem is with the ui but i couldn't figure it out
     
  41. airot87

    airot87

    Joined:
    Jan 18, 2018
    Posts:
    2
    i cant get my cube to rotate. i followed the video...wrote the code....nothing...i even copied the entire code from under the video and it still didnt work. here is the code under the code that i copied

    using UnityEngine;
    using System.Collections;

    public class Rotator : MonoBehaviour {

    void Update ()
    {
    transform.Rotate (new Vector3 (15, 30, 45) * Time.deltaTime);
    }
    }

    can someone explain to my how i can copy this code from the page and it not rotate my cube??
     
  42. gwnguy

    gwnguy

    Joined:
    Apr 25, 2017
    Posts:
    144

    1) The script is not attached to the game object?
    2) There are other compile/execution errors?
    3) The parameters shouldn't be int, they should be float:
    transform.Rotate(new Vector3(15.0f, 30.0f, 45.0f) * Time.deltaTime);
    (sorry, I can't test this, I'm not at my Unity dev machine)
     
  43. Mabus808

    Mabus808

    Joined:
    Jan 26, 2018
    Posts:
    2
    Hello, I'm having a problem with Unity not being able to drag and drop. I can't drop between the Project window and the Hierarchy window for example, nor dragging and dropping materials onto objects, etc.

    I've been able to find menu work arounds to progress through this tutorial, however, I'm at the part that I need to drag and drop the Pick Up item into my Prefabs folder, and I'm not able to do that.

    The inability to use this function is extremely frustrating and I have not been able to find an answer on how to fix it. I've restarted Unity, and I've even reinstalled it as a new install, with no joy.

    I'm using Unity 2017,3.0f3 Personal (64bit) on a Surface Studio running the Windows 10 Creative update.

    Any help would be greatly appreciated. I've attached an image of what's happening.

    Cheers!
     

    Attached Files:

    Last edited: Feb 1, 2018
  44. unity_5TRqyNFmsX8ifw

    unity_5TRqyNFmsX8ifw

    Joined:
    Feb 2, 2018
    Posts:
    1
    Hello guys, I met a problem here.
    My game works perfectly in the play mode,so I saved the Scenes and build. But when I run the built .exe file, my ball just penetrate through my pickups, and the Count doesn't change.
    I don't know how to fix it. Can anyone give me some advicese?
     
    Veleslav6 likes this.
  45. ThibaulT99

    ThibaulT99

    Joined:
    Feb 3, 2018
    Posts:
    1
    Hello ! I have a problem, when I use play mode the game works correctly but when I try to build and run it, nothing appear in the window it's just the basic landscape. Do you know where is the problem ?
     

    Attached Files:

  46. Nssis

    Nssis

    Joined:
    Feb 12, 2018
    Posts:
    1
    Hello. I am on the first part of the tutorial and was wondering if I was doing something wrong as my colors look almost metallic. I tried creating a new project and following the instructions exactly, but I always get the same result.

     
  47. Thoth6222

    Thoth6222

    Joined:
    Feb 12, 2018
    Posts:
    1
    Im getting a Roll-A-Ball could not be downloaded.
     
  48. Curtisr

    Curtisr

    Joined:
    Feb 8, 2018
    Posts:
    1
    my player in roll a ball wont collect the cubes it just phases through them what do I do
     
  49. TinaHsieh

    TinaHsieh

    Joined:
    Feb 9, 2018
    Posts:
    1
    Hi so when I click "play", the ball only moves when I also click, say "w", instead of moving automatically, is this what we want? In the tutorial it looks like it moves by itself......
     
  50. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Yes, that's how it's supposed to work. :) It's possible that earlier in the tutorial it moves on its own (I can't remember), but the game works with input.