Communicating scripts from C# to javaScript

Okay how do I call upon a function in a C# to a JavaScript?
and the whole purpose of this script it to get the wolf to attack you when you can’t
see it.
This script is attached to my player

JavascriptClass jscript = GetComponent("WolfAi");

when it is time for the wolf to pounce it will be told to pounce


not to advertise too much just the only way I can do this

It is possible to use both languages, but you need to place them in specific folders within your project, then the way they compile means that they only work one way i.e. C# gets compiled before JS, JS can see C# but C# cannot see JS. Read this link, especially Point 3 :

=> point 3 … This allows you to let different scripting languages interoperate. For example, if you want to create a Javascript that uses a C# script: place the C# script in the “Standard Assets” folder and the Javascript outside of the “Standard Assets” folder. The Javascript can now reference the C# script directly.

However, it would be more prudent of you to convert the scripts and use just one language, eg choose C# or uJS for your project. Then you will never have the problem of one language not being able to see the other. Also if you convert the scripts, you will actually learn how to read both uJS and C# !

Here’s some links I found useful in converting between C# and uJS :

(from my answer here : how to connect 2 scripts using C# / JS - Questions & Answers - Unity Discussions)

There are many issues related to using mixed languages in a project, and you ran into one of them.

Being able to reference JavaScript scripts from C# would require the script to be placed in a priority folder such as Standard Assets so it is compile before C# tries to reference it.

For more information see Script Compilation docs.