Roll the ball,why wont my ball roll?
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 );
}
}
I think Start() and FixedUpdate() are case sensitive names. Try to upper case each words first letter.
Still doesn't work, will have to just have to rewrite the script,there's no errors just wont move
Is your script set as a component of the gameobject you want to move ?
If not you can try : 1- to set it as a component of the gameobject. 2- to call the object you want to move externally with a "public GameObject gameObject;" variable, but I suppose you will need to change something in the GetComponent with this method.
Answer by hexagonius · Sep 17, 2015 at 09:48 AM
your Rigidbody must not be kinematic and speed not be 0 in the inspector.depending on the size of the ball the speed might just be too small, turn it up then.