- Home /
Unity 5 - new Animator State machine behaviour: ca we use UnityScript?
Is that possible? Are you forced to only use C#?
Even if I end up learning C#, the whole project is written in Javascript and I have the Script Execution order set to compile C# first so I wouldn't be able to access any of my scripts, right?
UPDATE: I just realized how unclear I was, I'm referring to Unity 5 new Animator feature: https://unity3d.com/learn/tutorials/modules/beginner/5-pre-order-beta/state-machine-behaviours
http://answers.unity3d.com/questions/201907/easiest-way-to-implement-finite-state-machine-in-j.html
This guy asked a similar question and appears to have found an answer.
http://docs.unity3d.com/$$anonymous$$anual/ScriptCompileOrderFolders.html
This document addresses your secondary question about compilation order. Note that C# is empirically superior to unityscript, and is strongly preferred by the overwhel$$anonymous$$g majority of unity veterans. Definitely worth making the switch for your next project.
I should have been more clear in my question, I'm asking about a specific Unity 5 Animator feature that apparently is C# only: https://unity3d.com/learn/tutorials/modules/beginner/5-pre-order-beta/state-machine-behaviours
Answer by AlwaysSunny · Jul 16, 2015 at 04:49 PM
95% sure you can't use .js for this. You may still be able to achieve what you want without converting your whole project to C#, (refer to the document I linked in my comment if you're having trouble) but these StateMachineBehaviour things need to be written in C#.
Not as intimidating as it sounds. There's a lot of overlap between the two languages, many differences are minor, and you won't need to learn all the major differences immediately.
Why do they need to be written in c#? Also, even if I become proficient in C#, I've already established the script execution order due to other limitations with plugins and c# scripts are being loaded AFTER Javascript, so I wouldn't be able to communicate with the core game scripts. Is this going to be supported in the future? Why a decision like this?
Can't speak authoritatively about specifics like this, but I don't think there are plans to change this. It's always been this way.
It has something to do with how scripts compile and subsequently identify one another; cross-language support is limited. I don't think this is a "decision" but rather a "limitation".
It's highly preferable to use a single language in a project for these reasons, and C# is highly preferable for numerous reasons. Evidently C#'s polymorphism and/or other exclusive features are key aspects of these State$$anonymous$$achineBehaviour things. I'm of the opinion that Unity should drop unityscript (and boo). $$anonymous$$ost of the time people have problems with them, the answer can be found in C#.
Basically:
.js is simple
C# is powerful
Sorry for sounding frustrated (and thanks for the replies so far) but I already know this. I've been working on this project for 3 years and changing everything to c# is NOT an option. I've learned the disavantages of javascript and will change languages on my next game. $$anonymous$$y question though, is about being able to use this new Unity feature with Unityscript, a STILL supported language in Unity, which I chose because I wasn't aware they were going to start doing language unique features as core as this one...
Depending on your specific situation, there may be some way to work around whatever trouble you're having with writing these in C#. I assume it's something about referencing .js scripts from within these State$$anonymous$$achineBehaviours?
I'm sure you're not the first person to want to do more than seems superficially possible with unity's compilation order shenanigans. I'd look into more generic questions on that issue. It's possible someone has devised a clever workaround for just such an occasion.
Again, I wish Unity would talk more about this kind of shortco$$anonymous$$g upfront, especially somewhere new developers would see it. So many newcomers gravitate towards .js for its apparent simplicity, but so often I see them struggle with issues which wouldn't arise in C#, or graduate to C# later saying "I wish I'd never bothered with unityscript".
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Alternative to Update 1 Answer
Script on two objects only runs as a single instance? 2 Answers
Incremental Move and stop 1 Answer