Error in code

I am getting this error
error CS0246: The type or namespace name ‘SerializeField’ could not be found (are you missing a using directive or an assembly reference?)
How do i fix this?

public class AddConstantVelocity : MonoBehaviour
{
    [SerializeField]
    Vector3 v3Force;

    [SerializeField]
    KeyCode keyPositive;
    [SerializeField]
    KeyCode keyNegative;

    void FixedUpdate()
    {
        if (Input.GetKey(keyPositive))
            GetComponent<Rigidbody>().velocity += v3Force;

        if (Input.GetKey(keyNegative))
            GetComponent<Rigidbody>().velocity -= v3Force;
    }
}

did you add using UnityEngine;

Oops! I guess I was overlooking that. Thanks!

1 Like