Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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

Discussion in 'Getting Started' started by Yuukizumanai, Feb 29, 2024.

  1. Yuukizumanai

    Yuukizumanai

    Joined:
    Jan 18, 2024
    Posts:
    3
    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
    }
     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,975
    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".
     
    MelvMay likes this.
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,589