Ball not moving in roll a ball

Sorry, I know this has been asked before but I couldn’t find the answer. I’m trying to build the Roll A Ball tutorial and am having trouble with ball movement. The rotation x and position z variables in the transform section of the inspector change when running (so it seems to be doing something?) but the ball is not moving. Using Windows PC.

Script is attached to Player and I think I corrected function capitalization. Here’s the script:

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);
		rigidbody.AddForce(movement*speed * Time.deltaTime);
	}
}

I fixed my problem after finding out the speed was set to 0… >.<

Thanks for all the help. The moveHorizontal and moveVertical were providing zero values, although I don’t know why. I closed the program, reopened, and reentered the script. Everything seems to be working now. I’m sure I did something originally to cause the problem.

Yes it is not working because you are not using keyboard while running the project. Use w, a, s or d to move your
Ball.

You are in FixedUpdate, I would think the values are already multiplied by deltaTime so as you are multiplying again, you end up with values extra small.

I found that I had to click on the game window to make it active to get the ball rolling.

The most possible answer is people copy paste the code from unity tutorial page and miss changing the speed value to a non-zero one, so every physics calculation gets nullified by multiplication with zero.

So zero-in and make it non-zero.

If you are using Unity 5.4 and if the roll a ball tutorial does not work, then just copy the C# code I have posted below.

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {

private Rigidbody rb;
// Use this for initialization
void Start () {
	rb = GetComponent <Rigidbody> ();
}

// Update is called once per frame
void FixedUpdate () {
	float moveVertical = Input.GetAxis ("Vertical");
	float moveHorizontal = Input.GetAxis ("Horizontal");

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

	rb.AddForce (movement * 15);
		
		

}

}

I found the solution. I had the same issues as you guys. I looked back at the video and you cant really see what the guy is doing on his keyboard. He says earlier in the video “make the player control the direction of the player”. This means if you did everything mentioned above right, YOU should be the one moving the player. After pressing play, move your up, down, left, and right keys to control the movement of the player. You should have no other problem if you did everything @AndrewCann @robertbu said.,Okay so I found the solution. I had the same problem. In the video, you can’t see the guy use his up down left right keys on his keyboard but he mentions earlier in the video “make the player be able to control the direction of the player”. This means, if you did everything said above correctly, YOU should be the one moving the sphere. After pressing play, use your right, left, up, and down keys on the keyboard to navigate the player.

My problem was also fixed after closing Unity and reopening. Can’t work out why it didn’t work to start with. The ball now moves around the plane though.

I also get the same issue.
After closing and reopening, everything goes fine.

public float Speed;
void FixedUpdate()
{
Vector3 Target = Camera.main.ScreenToViewportPoint(Input.mousePosition);
Target.z = transform.position.z;

    transform.position = Vector3.MoveTowards(transform.position, Target, Speed * Time.deltaTime);

}

If you copy and paste the completed script (as opposed to following along editing) then the speed gets defaulted to 0.0 so you need to set as explained slightly further on in the tutorial. Just set speed to about 0.1 works nicely for me.

My ball didn’t roll either, even with the speed multiplier. Just got it to roll after changing the Player Input Actions value to “InputActions (InputActionAsset)” (in my case they were set to None maybe by default). This came from searching the QuickStartGuide of the Unity Manual; I don’t know if it’s the best thing to do, but it got the ball rolling at it felt great :wink:

Even so, it gives the following two warnings:

Change stack is empty, did you call BeginChangeCheck first?
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

EndLayoutGroup: BeginLayoutGroup must be called first.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Can someone explain what they mean?

Good games everyone!