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);
}
}
Answer by Almop66 · Jul 02, 2017 at 07:08 AM
@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. THAN$$anonymous$$ YOU SO $$anonymous$$UCH!
Answer by ajf412 · May 30, 2016 at 03:53 AM
Make sure in your rigidbody component "Is Kinematic" and "Use Gravity" settings match the tutorial.
Your answer
![](https://koobas.hobune.stream/wayback/20220612081906im_/https://answers.unity.com/themes/thub/images/avi.jpg)