Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is the compiler telling me that there is no definition for .Enabled?

I’m following Brackeys’ tutorial on making a 3D game in Unity on Youtube and I’m up to the E05 (the collisions video) and I’m trying to make it so when you collide with the obstacle then the player movement is disabled. Here is the code:

Player Movement Code:

public Rigidbody rb;
public float forwardForce = 2000f;
public float sidewaysForce = 500f;

void FixedUpdate()
{
    rb.AddForce(0, 0, forwardForce * Time.deltaTime);
    if(Input.GetKey("d"))
    {
        rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0);
    }
    if(Input.GetKey("a"))
    {
        rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0);
    }
}

Player Collision Code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    public PlayerMovement movement;

void OnCollisionEnter(Collision collisionInfo)
{
    if (collisionInfo.collider.tag == "Obstacle")
    {
        movement.Enabled = false;
    }
}

However when I go back to Unity, the compiler tells me that PlayerMovement contains no definition for .Enabled. I’m sure I followed the video correctly, can anybody help?

>Solution :

You don’t followed video corretly….
You must write enabled in lowercase, Enabled in upper case don’t exit.

void OnCollisionEnter(Collision collisionInfo)
{
    if (collisionInfo.collider.tag == "Obstacle")
    {
        movement.enabled = false;
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading