I’m just starting off with Unity and am following the "Roll a Ball Game series from this website. I was able to get Part 1 of 8 but encountered errors while working on Part 2 despite copying the exact code. Any help would be much appreciated.
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);
}
}`
Errors:
-Assets/Scripts/PlayerController.cs(15,23): error CS0128: A local variable named `moveHorizontal’ is already defined in this scope
-All compiler errors have to be fixed before you can enter playmode!
UnityEditor.SceneView:ShowCompileErrorNotification()