- Home /
Problem is not reproducible or outdated
How do I fix my compiler errors? (Probably simple to solve)
(Background)
Hello. I am a total scrub at Unity and programing overall so if you've got a little more experience than I do, this will most likely be easy to solve. I've been trying to create some kind of 2D, platform game as my very first project and everything worked as it was supposed to until I tried to make the game restart when my character collided with the ground. I got the message "All compiler errors have to be fixed..." and "Assets/PlayerMove.cs(27,37): error CS1041: Identifier expected". I then removed the code I added but these messages is still there and prevents me from starting the game so I suppose I accidently removed/added something else.
(The code)
using UnityEngine;
using System.Collections;
public class PlayerMove : MonoBehaviour {
public float speedForce= 5f;
void Start () {
}
void FixedUpdate () {
if (Input.GetKey (KeyCode.A)) {
rigidbody2D.velocity = new Vector2 (-speedForce, rigidbody2D.velocity.y);
} else if (Input.GetKey (KeyCode.D)) {
rigidbody2D.velocity = new Vector2 (speedForce, rigidbody2D.velocity.y);
} else if(Input.GetKey (KeyCode.W)) {
rigidbody2D.AddForce(new Vector2(0, 10), ForceMode2D.Impulse);
}
else{
rigidbody2D.velocity = new Vector2 (0, rigidbody2D.velocity.y);
}
}
}
I would be really grateful if someone would care to solve and explain the problem since I can't seem to find any solution anywhere. I'm obviously new to this community aswell so be gentle guys.
even total scrubs need to format all of their code ;)
the line number of your error is meaningless without it... there's no line 27 in the posted code.
Nvm, I fixed it somehow.. Don't really know what I'm doing but atleast I can now start the game again.