'MusicController' does not contain a definition for 'PlayVictory'

I have no idea why my project is not compiling.

I run into the problem here: MusicController.instance.PlayVictory(); .

Assets\Scripts\GameManager.cs(82,34): error CS1061: ‘MusicController’ does not contain a definition for ‘PlayVictory’ and no accessible extension method ‘PlayVictory’ accepting a first argument of type ‘MusicController’ could be found (are you missing a using directive or an assembly reference?)

I’m totally clueless about what it could be.

So? Maybe open up the file and check it out. Maybe you need to write it or something.

1 Like

The error is stating that there is no such field/property/method named “PlayVictory” in your MusicController class.

How do I create a field/property/method named “PlayVictory” in my MusicController class?

You wouldn’t be trying to call the PlayVictory method if you weren’t doing a tutorial. The answer to your question lies in the tutorial you are following.

1 Like

Maybe you can start by stating what you think something like MusicController.instance.PlayVictory() should do. In general, what do you think that sort of thing should do? Should it cause an object to fall from the sky? Should it turn the lights on and off? Should it play an ad?

Whoever made the tutorial you’re following probably intended for you to have some understanding of what each line of code in the tutorial is there for. So, why do you think that line of code exists within the EndLevelCo method?

The same way as any other:

public class MusicController { 
   int myIntField;
   string myStringField;
   float myFloatField;

   void SomeMethod() {

   }

   int AnotherMethod() {

   }

   string AndAnotherMethod() {

   }


   int MyIntProperty { get; set; }
   string MyStringProperty { get; set; }
   float MyFloatProperty { get; set; }
}

See:
Defining fields in C#.
Defining methods in C#.
Defining properties in C#.

1 Like

I don’t want to sound rude, but you’ve been on the forum struggling with the very basics of developing with Unity for half a decade now, and still unable to get through tutorials. Have you considered switching to a game engine which is a bit easier; one that isn’t geared towards professional game developers?

Please post links to a game engine which is a bit easier; one that isn’t geared towards professions.

That sounds about right because before my car accident I was into VB pretty hard. So a simpler game engine sounds about right. What game engine should I try?