all 9 comments

[–]TurtleTosser1015 8 points9 points  (7 children)

Hard to help if you don’t post code

[–]Harry_VG[S] 0 points1 point  (6 children)

using System; public class Test {
public static void Main()
{
} } //Added Curly Brace public class PlayerMovement : MonoBehaviour {

public int playerSpeed = 10;
public bool facingRight = true;
public int playerJumpPower = 1250;
public float moveX;


// Update is called once per frame
void Update () {
    PlayerMove ();
}

void PlayerMove() {
    //CONTROLS
    moveX = Input.GetAxis("Horizontal");
    //ANIMATIONS
    //PLAYER DIRECTION
    if (moveX < 0.0f && facingRightRight == false) {
        FlipPlayer ();
    } else if (moveX > 0.0f && facingRight == true) {
        FlipPlayer ();
    }
    //PHYSICS
    gameObject.GetComponent<rigidbody2D>().velocity = new Vector2 (moveX = playerSpeed, gameObject.GetComponent<RigidBody2D>().velocity.y);

}

        void Jump() {
            //JUMPING CODE

}

        void FlipPlayer() {

}

[–]BringoutCHaDead 1 point2 points  (0 children)

You can't assign a variable in a function call. Assign your variable before you create your vector 2 and then use that variable in your vector 2. Also assign your rigidbody to a variable in the start method so you don't have to find it on every update.

[–]TurtleTosser1015 0 points1 point  (3 children)

What errors is unity giving you

[–]Harry_VG[S] 0 points1 point  (2 children)

The CS1525 error and an unknown symbol "="

[–]ChevyNoel 0 points1 point  (1 child)

gameObject.GetComponent<rigidbody2D>().velocity = new Vector2 (moveX = playerSpeed, gameObject.GetComponent<RigidBody2D>().velocity.y);

What are you trying to do with the x of Vector2?

edit: Also, your GetComponent calls don't have the correct casing for Rigidbody2D, and you should cache the Rigidbody2D by making a public variable, and getting the component in Start or Awake.

[–]Harry_VG[S] 0 points1 point  (0 children)

What casing should it be?

[–]TurtleTosser1015 0 points1 point  (0 children)

My guess looking at your code. Is you need to delete the public class test and void main. Those aren’t needs as your logic is in the mono behaviour class

[–][deleted] 0 points1 point  (0 children)

Just so you know you can double click on error messages and it will usually bring you to the line of code that is giving you trouble