Question by
TH3B3AST · May 09, 2017 at 07:53 PM ·
scripting problemerror
how to fix cs1014 error
hello i started with small project but at first 10 mins when i finsished script i didnt work. Here is my script can you tell me whats wrong what i should fix private Rigidbody rb { rb = GetComponent() }
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal")
float moveVertical = Input.GetAxis ("Vertical")
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical)
rb.AddForce(movement)
}
}
Comment
Answer by Matthewj866 · May 10, 2017 at 12:02 AM
Firstly, CS1014 means the compiler thinks you are trying to create a property and a specific accessor is expected but never found.
Rigidbody rb { rb = GetComponent() }
is not valid code. What you want is Rigidbody rb = GetComponent<Rigidbody>();
Also, you forgot your semicolons.
Example of how it should look:
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement);
}
Hope this helps.