Hi, I am coding my game in C# but I found a great asset on the store but its in JS. You are instructed to add the following code to the player, but I cant do this in my player manager script as its in c# so I have create a new JS script and attached it to the player.
The script is:
#pragma strict
private var speech : Speech; // this entity's speech reference
public var speechHolder : Transform; // position where speech bubble will stay, preferably right above a head
function Start () {
SetSpeech();
}
function Update () {
}
function SetSpeech()
{
speech = Instantiate(SpeechManager.bubble, Vector3.zero, Quaternion.identity).GetComponent(Speech);
speech.holder = speechHolder; // pass holder
speech.Stop();
}
Now, in order for the script to be called you are supposed to use:
speech.Say(string);
But in order to do that, it assumes you will be calling it within the same script, I however need to access this from various C# scripts that will trigger text.
I cannot for the life of me access it like I do any other script as it says that the namespace isn’t there.
I would normally use a method like:
GameObject thePlayer = GameObject.Find("ThePlayer");
PlayerScript playerScript = thePlayer.GetComponent<PlayerScript>();
But this just errors as I cannot call the PlayerScript by name, all my other C# scripts are showing, just not this JS one.
Please can someone help?
Or ideally, convert that JS into C# so I can attach into my main character script!!