'PlayerMovement' does not contain a definition for 'Main'

I follow the tutorial from samyam in Youtube

CS1061 ‘PlayerMovement’ does not contain a definition for ‘Main’ and no accessible extension method ‘Main’ accepting a first argument of type ‘PlayerMovement’ could be found (are you missing a using directive or an assembly reference?)

I get this error as well as I try to use Enable and Disable on OnEnable

Also, I saw the comment in yt about this problem and I see his comment said that Make sure you named it exactly Main with capital letters, also try regenerating the script. What is this mean?

Here is my script (not finish yet)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController02 : MonoBehaviour
{
private PlayerMovement controls;
private void Awake()
{
controls = new PlayerMovement();
}
private void OnEnable()
{
controls.enabled = true;
}
private void OnDisble()
{
controls.enabled = false;
}
private void Start()
{
controls.Main. //<<<This is my problem here
}

The problem is not in this script you shared, but in PlayerMovement. Open up your PlayerMovement script, check if it has a public variable or property called “Main”.

1 Like

FYI: How to post code on the forums: Using code tags properly

controls.Main.

This isn’t valid C# either. Maybe it’s a property as mentioned above or it’s a method, no idea.