Is Unity Intermediate Scripting tutorials still revelant to UnityScript users ?

I am trying to follow those tutorials (Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn), but I find myself thinking if it was only made for C# users ?

What I mean is, does this tutorial only apply for C# users since it is teaching OOP ? I found myself trying the Inheritance tutorial in javascript and I was greeted with several errors and warnings.

First, creating a class without derivating from Monobehaviour in javascript is not possible, but in the tutorial it was. I got an error saying that my class needed to derivate from MonoBehaviour or else Scriptable object.

Second, the “new” keyword when instancing a derivated class apply also for a C# usage. It will work for Javascript, but I get a warning message telling me to use instead AddComponent.

Third, the tutorial don’t tell me how to make it work in Unity Editor. Do I need to only attach the FruitSalad class to an object, or do I need also the Fruit and Apple Class to be also attached to that game object.

What do you think ?
Is OOP still be possible in javascript with these tutorials ? If not, what could be the right piece of code I should use if I want to program OOP javascript for that tutorial ?

The intermediate scripting tutorials are more focused on C# at the moment, but not all of the lessons will apply to C# only. As you progress in game development it becomes more important to know more of the features of the language that you use. As the examples from the tutorials show, features like inheritance can be very powerful in helping you create games. Unfortunately we simply don’t have the time to cover everything in every language. As such we had to choose the language that would make everything that each script was doing as clear and plain as possible. Since there is a lot that is hidden in javascript (for example the implicit class declarations) we went with C#. In order to make a javascript not inherit from monobehaviour you need to make an explicit class declaration.

I’m not sure, but it sounds like you might be a little confused over the use of classes in Unity. All scripts that are attached to gameobjects are monobehaviours. This means that they inherit from the monobehaviour class. This is quite obvious (once you know about inheritance) in C# since you can see : MonoBehaviour at the top of every class declaration. However, in JS, since the declaration is implicit this isn’t as obvious. If you try to create a “new” instance of a monobehaviour then you will get the error that you mentioned.

My honest advice in this situation would be to have a go at C#. That may seem daunting or unpleasant (you’ve already spent the effort learning JS, so why should you bother?) but it will be worthwhile in the long run. Having already learnt JS, you’re more than halfway there! Before intermediate scripting, the differences are pretty much just variable and function declarations. They are all summarised in the beginner scripting lesson comparing the two languages.

Again, this may sound like a lot of effort, but it’s less than you think and it will be worth while in the long run. Think of how much more powerful your games can be with all the OOP tools working for you!

I hope this helps.