Click here to Skip to main content
15,944,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<pre>using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveLeft : MonoBehaviour
    public float speed = 20f;
    private float lowerBound = -25f;

    private PLAYERCONTROLLER playerControllerScript;

    // Start is called before the first frame update
    void Start()
        playerControllerScript = GameObject.Find("Player").GetComponent<PLAYERCONTROLLER>();

    // Update is called once per frame
    void Update()
        if (playerControllerScript.gameOver == false)
            transform.Translate(Vector3.left * Time.deltaTime * speed);

        if (transform.position.y < lowerBound)


What I have tried:

Help please.Is there anything wrong in it?
error CS1061: 'PLAYERCONTROLLER' does not contain a definition for 'gameOver' and no accessible extension method 'gameOver' accepting a first argument of type 'PLAYERCONTROLLER' could be found (are you missing a using directive or an assembly reference?)
Updated 20-Jun-20 19:17pm
Garth J Lancaster 20-Jun-20 21:13pm    
Why is 'PlayerController' uppercased as in here
private PLAYERCONTROLLER playerControllerScript;
and here
playerControllerScript = GameObject.Find("Player").GetComponent<PLAYERCONTROLLER>();

On the little bit of code you've put, there is no reason - should it not be PlayerController ? (unless something is happening elsewhere in the code you havent shown us)
ariadna villavicencio gamarra 20-Jun-20 21:41pm    
Thats the link to other script, which is named as "PLAYERCONTROLLER"
F-ES Sitecore 21-Jun-20 9:39am    
It means there is no field on PLAYERCONTROLLER called gameOver, it's as simple as that. To fix it you need to make sure that there is a field called gameOver. It might be that such a field does exist but the case is different, ie it might be called GameOver. c# is case sensitive so it matters that the case is exact. If it isn't the case then ensure gameOver is marked as public so it can be accessed by code in other classes.

1 solution

The error message is pretty explicit: the class does not not contain a method of that name.
You are either trying to call a method on the wrong class (like calling Substring on an int value for example) or you forgot to add the method to your class.

And Garth is right: the name PLAYERCONTROLLER is a bad idea, C# good practices mean that classes should be CamelCase: PlayerController is more obvious where the "words break" and easier to read to boot.
This can be a problem with some classes where the name becomes ambiguous because it could e broken in several places - think about the internet websites with "bad meanings" because case is irrelevant in domains:
EXPERTSEXCHANGE  ExpertSexChange or ExpertsExchange?
PENISLAND        PenisLand or PenIsland?
THERAPISTFINDER  TheRapistFinder or TherapistFinder?
It's a very good idea to stick to established conventions!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900