False CS1003 error

I am following a tutorial for first person games and I’m getting this error:
Assets/PlayerMovement.cs(7,21): error CS1003: Syntax error, ‘,’ expected
Here is my code:

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public CharacterController controller;

    public float speed 12f;
    // Update is called once per frame
    void Update()
    {
        float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");
   
    Vector3 move = transform.right * x + transform.forward * z;

    controller.Move(move * speed * Time.deltaTime);
    }
}

Does anybody know how to fix this?

Line 7 is in fact the problem, as you probably meant to write:

public float speed = 12f;

Your line 14 though is confusing, as reading it will require most people to go google “C# math order of operations”. I’d add additional parenthesis to make the order explicit. But there isn’t a code error there or anything.

You forgot an equals sign when assigning the value to your float in line 12. The error message may not be exactly helpful, but at least it shows you the right line. The compiler is just confused. It should be public float speed = 12f;

Edit: You were one second faster @Joe-Censored :smile:

1 Like

Thanks, it worked!