Search Unity

Official Roll-a-ball Tutorial Q&A

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

  1. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    if you look in project browser window, there should be a done folder, and in that theres one for Scenes, and if you double click the done scene, you can try the completed game.
     
  2. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    just a couple of observations any my thoughts;
    deactivating - you can deactivate a gameobject/component so that its no longer actively involved in the scene but still there. but as long as you have a reference to that object you can reenable it again.

    destroying - when you mark an object for destruction, this is irreversible, you cannot get that object instance back, and will generate a small ammount of garbage collection.

    so if you are definetly sure that you will never need a specific instance of an object or component again, destroy.
    But if you think you might want to have it back at some point, disable it, and hold a reference to it, so you can reenable it again.

    in the context of what you could do with this game, you could disable each cube as you collect them, and if you restart the game you could effectively just reenable them all again. this would save on loads of destroying objects and reinstantiating them again, bit more efficient, but at this stage its negligible. hope that helps a bit, thats just my take on it tho.
     
  3. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    have a check, have you got the playercontroller script added to the camera instead of the player?
     
  4. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    cool that you want to try and experiment, have a look at one of Adams live training sessions here
    https://unity3d.com/learn/tutorials/topics/scripting/how-communicate-between-scripts-and-gameobjects

    there are loads of other hour long live sessions covering a wide range of topics and levels, and they are all archived to watch later and posted here..
    https://unity3d.com/learn/live-training
     
  5. Pocketknife316

    Pocketknife316

    Joined:
    Sep 21, 2016
    Posts:
    6
    THANK YOU SO MUCH, OBO SHAPE!!!!!!!!!!!
     
  6. WikiAdam

    WikiAdam

    Joined:
    Aug 9, 2014
    Posts:
    2
    Been following along with the tutorial and everything has been going GREAT right up to the point where the Player object is supposed to make the Pick Up objects go away upon collision. Instead, the Player object just rolls right through the Pick Up objects without affecting them at all.

    I believe I have the code exactly as the instructor wrote it (i.e., I wrote "OnTriggerEvent" and not "onTriggerEvent"), and my tag is exactly the same as my string ("Pick Up"), no extra spaces. And I checked "Is Trigger" on the prefab so all of the boxes have it checked. Anyone have any ideas why this isn't working? Here's my code, and I also attached a screenshot of the Unity Editor.

    If anyone knows what I did wrong, please point it out! Many thanks!


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

    void OnTriggerEvent(Collider other)
    {
    if (other.gameObject.CompareTag("Pick Up"))
    {
    other.gameObject.SetActive (false);
    }
    }
    }
     

    Attached Files:

  7. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Morning,

    Just looking at your code, where you have
    Code (CSharp):
    1. void OnTriggerEvent(Collider other)
    this should be changed to read

    Code (CSharp):
    1. void OnTriggerEnter(Collider other)
    so to use the OnTriggerEnter method. should be good to go :)
     
  8. WikiAdam

    WikiAdam

    Joined:
    Aug 9, 2014
    Posts:
    2

    Gah! I knew it was something stupid I missed. Thank you so much for the quick response, OboShape!
     
    OboShape likes this.
  9. oeiandruw

    oeiandruw

    Joined:
    Oct 12, 2016
    Posts:
    1
    why the ball did not want to stop when I'm no longer push the button ?, anyone know how to stop the ball slowly.
     
  10. HACBACK17

    HACBACK17

    Joined:
    Oct 3, 2016
    Posts:
    1
    Hello Adam and everyone
    My question is related to this video.

    Code (CSharp):
    1.     void OnTriggerEnter(Collider other)
    2.     {
    3.         if (other.gameObject.CompareTag ("Pick Up"))
    4.         {
    5.             other.gameObject.SetActive (false);
    6.         }
    7.     }
    I have a problem understanding the code. What I don't understand is what is this gameObject? I think it is a reference of GameObject, but I don't see anywhere in the code that the GameObject has been initialized there.

    Need help.
     
    Last edited: Oct 13, 2016
  11. TrillionJaBroni

    TrillionJaBroni

    Joined:
    Oct 13, 2016
    Posts:
    2
    Unity 5 - Roll a Ball game - 5 of 8: Creating Collectibles - Unity Official Tutorials



    Problem:
    Material doesn't apply its self to the prefab i.e. I drag the material onto the prefab object, but it does not apply the material to the other duplicates(pickups)
    Also if I try applying material directly onto a pickup and clicking apply, it doesn't change the rest of the instances when I try to apply. Whats happened?

    When I hover over the apply button , I get the warning that "You have broken the prefab connection... " Also "GameObject reference missing", but this script warning has existed since the tutorial and things seemed to work until now.

    There is no problem with the pick ups rotation or ball movement.


     
  12. mason173robinson

    mason173robinson

    Joined:
    Oct 15, 2016
    Posts:
    3
    can anyone help me , im using microsoft vs here is the code
    here is the error
    Severity Code Description Project File Line Suppression State
    Error ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index Solution 'ROLL A BALL' ‎(1 project) /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs 633


    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);
    }
    }
     
    Last edited: Oct 15, 2016
  13. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    So does the ball continue to move at a steady velocity? or does it move very slowly when you release the movement keys?
     
  14. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    the prefab for the pickup that you have in the prefab folder will be used as the template for all the pickups.
    so any changed to that will propogate through to all instances of that prefab in the scene.

    so dragging that pickup from the prefab folder into the scene will create an instance of that prefab, and will be bound to it.
    check your pickup prefab in the prefab folder, you seem to have a missing script in the inspector. so highlight your pickup in the prefab folder and delete the missing script that might be causing some issues.

    drag a copy of that prefab into the scene and see how it looks after clearing any missing script errors.
     
    TrillionJaBroni likes this.
  15. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Have you tried shutting down unity and reopening, has that changed anything?
    at first glance doesnt seem to be anything awry with your script.
     
  16. TrillionJaBroni

    TrillionJaBroni

    Joined:
    Oct 13, 2016
    Posts:
    2

    Thank you
     
  17. Rats_On

    Rats_On

    Joined:
    Oct 18, 2016
    Posts:
    1
    My ball doesn't move after doing all these same as tutorial. How can i solve it.
     
  18. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    can you double check that the script is attached to the player please.
    can you also check that the rigidbody component that is on the player does NOT have the 'isKinematic' box checked.

    are you getting any errors showing in the console?
    if that doesnt sort it, can you please post a copy of your PlayerController script so we can have a look (using code tags please to make it easier to read, see sig for help)

    Cheers
     
  19. mason173robinson

    mason173robinson

    Joined:
    Oct 15, 2016
    Posts:
    3
    i have restarted it many times but keeps pulling up this code , normally it will start with no error in vs , but after trying to add it to the player it will pull this code, ive deleted the script started it IN VS over again , tried deleting the project and restarting it

    started new project same error????
     
    Last edited: Oct 19, 2016
  20. mason173robinson

    mason173robinson

    Joined:
    Oct 15, 2016
    Posts:
    3
    upload_2016-10-18_17-23-43.png
    i tired mono develop same problem
     
  21. jua360

    jua360

    Joined:
    Oct 21, 2016
    Posts:
    1
    Thank you for the tutorial. Everything works, however I haven't compiled it into a standalone app. I wanted to know I'd add sound effects for when the ball hits a cube. Perhaps looping background. Just a thought. Thanks again & I look forward to more tutes.
     
  22. anotheracountproductions

    anotheracountproductions

    Joined:
    Aug 25, 2016
    Posts:
    1
    I've got a problem with making this simple game work. Every time I try to test my movement script, this pops up in the console: http://prntscr.com/cy249z

    I'm not sure how this is going wrong, but, I have a few ideas of where the problem could be sitting, as seen in these screenshots.
    http://prntscr.com/cy25o7
    http://prntscr.com/cy25x7
    http://prntscr.com/cy263e

    And the mover script is here under this spoiler.
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. publicclassPlayerController:MonoBehaviour{
    6.  
    7. publicfloatspeed;
    8.  
    9. privateRigidbodyrb;
    10.  
    11. voidStart()
    12. {
    13. rb=GetComponent<Rigidbody>();
    14. }
    15.  
    16. voidFixedUpdate()
    17. {
    18. floatmoveHorizontal=Input.GetAxis("Horizontal");
    19. floatmoveVertical=Input.GetAxis("Vertical");
    20.  
    21. Vector3movement=newVector3(moveHorizontal,0.0f,moveVertical);
    22.  
    23. rb.AddForce(movement*speed);
    24. }
    25.  

    Also, while running debug in Monodevelop, this interesting tidbit popped up too: http://prntscr.com/cy28jr.
     
  23. ThatOneGuy153

    ThatOneGuy153

    Joined:
    Oct 27, 2016
    Posts:
    1
    My canvas is several times bigger than it should be, the bottom right corner of it is at 0, 0, 0, and my text won't display in game view. Please help, I can't find anything about this anywhere else.
     
  24. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836

    One thing to bear in mind the filename of the script and the class name within the script must be the same.

    so looking at your script the line that reads
    Code (CSharp):
    1. public class PlayerController : MonoBehaviour {
    so your class name is ' PlayerController ' there, so your filename must match this as in ' PlayerController.cs ' .

    Its the way Monobehaviours/Unity works, so ensure that these are the same, and try and remove and readd this script to the player and test again.
     
  25. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Have a look through the learn site tutorials or some of the live archives for more info
    https://unity3d.com/learn/tutorials/topics/audio/sound-effects-scripting?playlist=17096

    you could always work through the SpaceShooter tutorial series as SFX is covered in that, again thats on the learn site tutorial section.
     
  26. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Have a look at the UI tutorials here
    https://unity3d.com/learn/tutorials/topics/user-interface-ui

    theres also a few live hour archived session outlining the UI at the bottom of that page as well that might help give an outline.
     
  27. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Sent you a PM to try something out.
     
  28. gaming4own

    gaming4own

    Joined:
    Oct 31, 2016
    Posts:
    1
    Hi,

    I am a total noob.

    I am wondering where can i find the asset for the tutorial provided by unity. If roll a ball is the tutorial, where can i find the asset of it?
     
  29. Joemayami

    Joemayami

    Joined:
    Oct 31, 2016
    Posts:
    1
    This is the error code i get after assigning a playercontroler script... need help in fixing this NullReferenceException: Object reference not set to an instance of an object PlayerController.FixedUpdate () (at Assets/Scripts/PlayerController.cs:19)
     
  30. Ultimate360

    Ultimate360

    Joined:
    Oct 28, 2016
    Posts:
    27
    Hi, I'm a bit confused, mixed up new knowledge; I'm currently working now with space shooter; I'm just here to ask...

    What's the difference between other.gameObject.CompareTag(" ") and other.CompareTag(" ")?
    Same apply with other.gameObject.tag == " " and other.tag == " "?
    Are they the same?
     
  31. Tazvaz

    Tazvaz

    Joined:
    Nov 1, 2016
    Posts:
    4
    I have copied the script from the tutorial page. In visual studio I don't get any errors but in Unity it says "The associated script cannot be loaded, please fix any compile errors and assign a valid script".
     
  32. Tazvaz

    Tazvaz

    Joined:
    Nov 1, 2016
    Posts:
    4
    There are no assets for roll a ball tutorial. Watch the first video.
     
  33. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    without seeing your script, it could be that the variable rb that holds the Rigidbody reference has not been set.
    if rb is not set (ie NULL) and something tries to use it it will generate a similar error.

    check your Start() method, ensuring that it has a capital S, otherwise it wont get called, it wont show an error, it just simply wont work.
    Code (CSharp):
    1.  void Start ()
    2.     {
    3.         rb = GetComponent<Rigidbody>();
    4.     }
    see how you get on.
     
  34. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    check that the Class name in your script, is identical in spelling to that of the filename of that script..
    for instance, take the example of a line from the PlayerController script.

    Code (CSharp):
    1. public class PlayerController : MonoBehaviour {
    the class here is " PlayerController", so the fine name for this script MUST be "PlayerController.cs"

    its a prerequisite how Unity calls the MonoBehaviours i believe.

    if they didnt match and you then renamed it correctly, you may have to remove that script from the GameObject and readd it.

    See if that helps.
     
  35. TigerRace

    TigerRace

    Joined:
    Nov 4, 2016
    Posts:
    1
    What do I do? How do I animate stuff? How do I make characters? How do I code? I am so confused and I have no idea what to do on unity! Can someone please help me begin? I made games on scratch.mit.edu and they were easy to make, but this is completely different.
     
  36. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Evening, firstly ... its a lot to ask for in one post and youre not going to learn everything at once, but you've taken the first step on a journey by opening Unity and asking questions :)

    As a bit of advice, start at the beginning, let yourself get used to things from the ground up, the rest will come as confidence and understanding grows.

    Firstly theres the Unity Learn site https://unity3d.com/learn there are alot of resources and tutorials on there to get you started.

    Seen as you have found this forum thread, why not start working through the RollABall tutorial and see how you get on following that.

    https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial

    and most important, enjoy yourself. Any questions, the community here is fantastic and always willing to help.
     
  37. TheBeff

    TheBeff

    Joined:
    Nov 4, 2016
    Posts:
    2
    Heyo -

    I keep getting a NullReferenceException on the below code for my SetCountText function, but I cannot for the life of me figure out why:

    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.     public Text countText;
    9.  
    10.     private Rigidbody rb;
    11.     private int count;
    12.  
    13.     void Start ()
    14.     {
    15.         rb = GetComponent<Rigidbody>();
    16.         count = 0;
    17.         SetCountText ();
    18.     }
    19.  
    20.     void FixedUpdate ()
    21.     {
    22.         float moveHorizontal = Input.GetAxis ("Horizontal");
    23.         float moveVertical = Input.GetAxis ("Vertical");
    24.  
    25.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    26.  
    27.         rb.AddForce (movement * speed);
    28.  
    29.     }
    30.  
    31.     void OnTriggerEnter(Collider other)
    32.     {
    33.         if (other.gameObject.CompareTag ("Pick Up"))
    34.         {
    35.             other.gameObject.SetActive (false);
    36.             count = count + 1;
    37.             SetCountText ();
    38.         }
    39.     }
    40.  
    41.     void SetCountText ()
    42.     {
    43.         countText.text = "Count: " + count.ToString ();
    44.     }
    45. }
    46.  
    here's the exact error:
    NullReferenceException: Object reference not set to an instance of an object
    PlayerController.SetCountText () (at Assets/Scripts/PlayerController.cs:43)
    PlayerController.Start () (at Assets/Scripts/PlayerController.cs:17)​
     
  38. TheBeff

    TheBeff

    Joined:
    Nov 4, 2016
    Posts:
    2
    ACK I solved this...just needed to keep watching the video for ten more seconds...

    It's not an error in my code - I failed to assign the public variable in my PlayerController component to the CountText GameObject within the Unity Interface. Once I did that, I was ALL GOOD!

     
    OboShape likes this.
  39. FinL2K

    FinL2K

    Joined:
    Nov 8, 2016
    Posts:
    3
    i did everything that you sed to move object but it don't work first that i did is that code but in unity it dont shoved that speed where you can select:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerControler : MonoBehaviour {
    5.  
    6.     public float speed;
    7.  
    8.     private Rigidbody rb;
    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. }
    second code that i tried is this:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerControler : MonoBehaviour {
    5.  
    6.     public float speed;
    7.  
    8.     private Rigidbody rb;
    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 * 50);
    23.     }
    24. }
    and it still didnt moved
     
  40. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    One thing to watch out for is the console window, as it will show an error when you use the code above.
    or look at the lower left of the editor and it shows you the most recent error.

    Looking at your code, where you currently have
    Code (CSharp):
    1. void start()
    this has to be Start() with a capital S, C# is case sensitive, try
    Code (CSharp):
    1. void Start()
    using these standard methods, if you miss spell or use incorrect case, they wont generate an error, they just wont get called.

    the reason why its not working is that the Start() method is not getting called as it has the wrong case.
    therefore will not set your 'rb' variable, so when you try to use it later in the FixedUpdate() method, 'rb' is null as it hasnt been assigned a value.
     
  41. FinL2K

    FinL2K

    Joined:
    Nov 8, 2016
    Posts:
    3
    amm... it still dont work and where to find console? btw in unity where is script shows:
    The associated script can not be loaded.
    Please fix ane compile errors and assign a valid script

    but i dont know what error
     
  42. FinL2K

    FinL2K

    Joined:
    Nov 8, 2016
    Posts:
    3
    i find 2 problems in console that i cant figure it out so problems are:

    The referenced script on this Behaviour (Game Object 'Player') is missing!

    The referenced script on this Behaviour is missing

    http://www.part.lt/img/51874253f5d8c27a5f62fafa02039d33346.png

    http://www.part.lt/img/ca01fecbe19824799bf729032113397a962.png
     
    Last edited: Nov 8, 2016
  43. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Ah, sorry, I didnt notice this last night ( just off nightshift and a little tired eyes).

    A thing to look out for is that your MonoBehaviour class name in your script and your filename must be exactly the same.
    Its one of the caveats that Monobehaviour / Unity requires to be able to be called and work correctly.

    Your filename is 'PlayerController.cs', but the class name in your script is PlayerControler (only has one 'l'), you will have to correct this in your script.

    where you have this line in your script
    Code (CSharp):
    1. public class PlayerControler : MonoBehaviour {
    you have to change this to be the same as your script filename, so change to the following.
    Code (CSharp):
    1. public class PlayerController : MonoBehaviour {
    you may have to remove the script from your player and then readd it, just to get it to recompile.
     
  44. Maja153

    Maja153

    Joined:
    Nov 9, 2016
    Posts:
    1
    I keep getting the error "Unexpected symbol `Vector3´"
    The code is identical to the 2nd step of the roll-a-ball tutorial, but i noticed that the "Vector3"s are not blue, but instead black. here is the script:

    (PC is short for Player Control, but that works fine)

    using UnityEngine;
    using System.Collections;

    public class PC : 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);
    }
    }
     
  45. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    your missing the semicolon at the end of this line in your FixedUpdate.
    Code (CSharp):
    1. float moveVertical = Input.GetAxis ("Vertical")
     
  46. Goby03

    Goby03

    Joined:
    Nov 11, 2016
    Posts:
    11
    Hello !
    Sorry to bother you.
    I am trying to learn how to use Unity3D for a school project. I am following your tutorial. But I have a problem and I think, it come for the input manager configuration. I don't find how configure the "play" key shortcuts. Could you help me ?

    Sorry for my english, it's not my native language. So if you don't understand what I say, tell me and I will try to explain with differents words.
     
  47. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Afternoon,

    What section of the tutorial are you having problems with?

    As far as playing/testing the game, there is the playhead controllers at the top of the editor window

    or under Edit > Play from the main Editor menu. and that will start playing the game.

    or is it the script that isnt working? if its the script, can you post what you have please so we can have a look at it to try and help. (use code tags please when posting code, just to make it easier to read, its along the top bar when making a post)
     
  48. Goby03

    Goby03

    Joined:
    Nov 11, 2016
    Posts:
    11
    I am having problem with this section : https://unity3d.com/fr/learn/tutorials/projects/roll-ball-tutorial/moving-player?playlist=17141
    The ball does'nt move.

    I use the script under the video with the same name for the differents objetcs but it's doesn't work. And into the console, I don't have mistake.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    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. }
     
  49. OboShape

    OboShape

    Joined:
    Feb 17, 2014
    Posts:
    836
    Ah ok, a couple of things to check if you could.

    - is the script attached to the player?
    - Have you set the speed in the inspector, just incase its 0?
    - Check the Rigidbody component that is on the player to see if 'isKinematic' is unchecked.
    ( if this is checked it will ignore all physics forces that we try and apply and wont move, so ensure its unchecked)
     
    Goby03 likes this.
  50. Goby03

    Goby03

    Joined:
    Nov 11, 2016
    Posts:
    11
    Thanks ! I am an idiot ! I forget to change the speed value.
    Now, it works ! :)