- Home /
Question by
unfree · Aug 25, 2016 at 05:42 PM ·
movement scriptroll a ball
what is wrong with my script?!?!?!
https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial/moving-player?playlist=17141 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 dont under stand, this is from the site itself
Comment
Answer by Jessespike · Aug 25, 2016 at 05:51 PM
There is nothing wrong with the script.
Does the sphere have a RigidBody? Add one if not. (See video at 0:20)
Is the script attached to the sphere? (See video at 2:25)
You need to set the speed in the inspector. Change it so it is not 0. (See video at 14:05)
You shouldn't have any problems if you follow the video.