How can that be when PlayerController is a class. Sry if i sound like an idiot
I was following a tutorial and this was mentioned because of the Curly brackets and semi colon.
In your example, this line of code first calls static method “Find” of GameObject.
This method returns a GameObject (which can be null), and from the result the line calls GetComponent method requesting return type of PlayerController.
Internally GetComponent does something akin to iterating through all attached components, until one of desired found, and then returns it.
The value is then assigned to playerControllerScript.
That’s called generics. Essentially, C# generics is a way to allow for types to be parameters when defining classes, interfaces, methods, and delegates, enabling more code reusability and type safety.
The GetComponent, in this case, is a generic method which returns a component of the requested type, if it is attached (otherwise null).