Roll-a-ball tutorial: problem with movement

Hi guys, i have a problem with the tutorial and i am sure it is only a mini mini thing i am missing, but i cannot find it out.

I used the following code from the tutorial for moving the sphere:

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

The code looks ok - no error messages.
I set the speed param to 1000, but unfortunatedly i cannot move the sphere with the keys. I followed all other instructions in the turoial, too.

I found a similar post in here, but not the answer how the poster got it running.

Has anybody any hint for me?

Thanks in advance.

Hi…Tasmia suggested you right but you can do lil modification

just translate ball in global axis as translating it in local axis will result in rotation problem …ball will not translate as its local axis changes when ball rotates . if you restrict rotation then ball will skid and will not look real. So translate ball in global axis. for that I have used Space.world in Tasmia’s Code

using UnityEngine;
using System.Collections;

public class rollbal : MonoBehaviour {
	
	public float speed;
	
	void Update()
	{
		float moveHorizontal = Input.GetAxis ("Horizontal");
		float moveVertical = Input.GetAxis ("Vertical");
		
		Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
		transform.Translate(movement*speed*Time.deltaTime,Space.World); 
		
	}
}

using UnityEngine;
using System.Collections;

    public class s : MonoBehaviour {
     
    public float speed;
     
    void FixedUpdate()
    {
    float moveHorizontal = Input.GetAxis ("Horizontal");
    float moveVertical = Input.GetAxis ("Vertical");
     
    Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    transform.Translate(movement*speed*Time.deltaTime); 
   
    }
    }

try Translate rather than AddForce… its working fine for me
and most important … reduce your speed to 1

I got it working now. As i thought it was just a little adjustment in the preferences to get it working - the code was correct.

The code looks fine, it’s in line with the Unity Roll-A-Ball tutorial.

Make sure that your input is getting through - print out the moveHorizontal and moveVertical variables in FixedUpdate (you can use Debug.Log(moveHorizontal) to print the value to the console. Do the values remain 0 when you press the keys? If so, your input is getting lost somewhere, which will be the cause of the problem.