Roll a Ball, sphere flies when I click play

I’ve just started learning Unity and I don’t know what’s going on cause when I write the script and press Play, everything works fine but the sphere keeps flying. The position of the sphere is how it’s taught in the video (x: 0, y:0.5, z:0) but when I click play It changes y=1. Can anybody help me?

Here is the script

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

}

2 Answers

2

@LukeTheLukian I had this problem as well, I fixed it by selecting “Ground” (whatever you called your floor) under scene 1 and un-checking “Convex” which can be found in the “Mesh Collider” component.

You're awesome sir. I struggled with this ALL DAY LONG, by doing what you did it simply solved it. THANK YOU SO MUCH!

Make sure in your rigidbody component “Is Kinematic” and “Use Gravity” settings match the tutorial.