- Home /
Duplicate Question
Roll-a-ball Compiler Error, code is perfect, yet no movement.
I am new to Unity, and yes, I know similar questions have been posted and I have tried everything suggested on all of them. I cannot move my ball still.
The compiler error message says I cant complete the action with out fixing all errors, but I have no errors on MonoDevelop at all. Unity is giving me at the bottom of the window a line reading "Assets/_scripts/playercontroller.cs(8,12): error CS1519: Unexpected symbol'void' in class , strut, or interface member declaration."
I HAVE COMBED THE CODE TO ENSURE ITS THE SAME (Just in case though I will put a copy of it in here). I would like to finish the tutorial before I move on to the next one.
using UnityEngine;
using System.Collections;
public class playercontroller : MonoBehaviour
{
public float speed ()
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement*10.0f);
}
}
To find errors, open the console window in Unity. You can double click on an error message in the console window to highlight that error in $$anonymous$$onodevelop. Your problem is line the line where you declare 'speed'. You are also not using 'speed' in your script. Here is the script with a couple of fixed. It will compile:
using UnityEngine;
using System.Collections;
public class playercontroller : $$anonymous$$onoBehaviour
{
public float speed = 10.0f;
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical) * speed;
rigidbody.AddForce(movement);
}
}
Lol. By definition code cannot be perfect and have a compiler error.
Follow this Question
Related Questions
Weird compiler error code 1 Answer
Problem with custom shaders (surface function error) 0 Answers
What is the error? 2 Answers
Internal Compiler Error caused by Visual Studio project? 0 Answers
Help with Error CS1519? 1 Answer