Forum rules - please read before posting.

Get name translation from a Character Prefab

Hi hi,

I'm hitting myself against a situation that I do not quite understand why it happens.

I need the characters to be able to speak even if they are not in the scene. I have managed to solve this by using prefabs with ConstantID. All perfect.

However, when I try to access the translation of the name using the following code I get a message at the Debug console saying "Cannot find translation for 'Char2Name' because the text has not been added to the Speech Manager."
speakingCharacter.GetName(AC.Options.GetLanguage())

The problem is that Char2Name is actually added to the Speech Manager. I have tried backtracking the problem, and the displayLineID field is assigned to -1 at some point that I have not been able to locate.

I'm trying something too complicated when there is a simpler solution to this situation, other than having an instance of each player or npc in all scenes?

Thanks,
Marc.

Comments

  • Does the "Char2Name" entry in the Speech Manager relate to a scene-instance of the character? It's likely that the prefab itself is not being gathered.

    If you enable Debug mode in the prefab's Inspector, you can try updating the displayLineID field to match that of the Speech Manager's line ID.

    Character prefabs are gathered, however, if they are Players listed in the Speech Manager. Another approach you may want to consider - if your game features NPCs that move between scenes - is to enable Player-switching, and assign those NPCs as Player prefabs. Such characters can be accessed from any Action at any time, moved between scenes and updated automatically - a tutorial on this topic can be found here.

  • Thanks for the quick reply, Chris.

    I already use Player-switching, since the game has different characters that never meet each other in a scene, and they are able to talk to each other through some kind of telephone.

    So I have the controllable characters and the npcs as prefabs, and the controllable ones are assigned in the Player-switching.

    Indeed, the displayLineID it's asigned as -1 at the debugged inspector, and updating that field to match the Speech Manager's line ID solved the problem.

    Will I have to manually modify this for all current characters and those I create in the future? Or am I creating the characters incorrectly and that's why they are assigned the -1 when prefabing them?

  • To be clear: are the characters that have the issue Players that are assigned in the Settings Manager? They should be being gathered in that case. What is your AC version?

    Check Char2Name's entry in the Speech Manager - is it listed for a particular scene?

  • AC v1.73.4, and yes, both assigned or not assigned have the same issue.

    Char2Name's entry is listed as (No scene) while NPCs are listed in their own scenes.

    All of them have the -1 at the displayLineID.

  • Sorry for not picking up on this sooner, but displayLineID isn't modified as part of the translation process - instead it's lineID that the Speech Manager should be affecting.

    The lineID is then transferred to displayLineID in the character's _Awake function.

    As the characters' lineID values being properly set?

  • The lineID value is correct. The displayLineID is never updated if I set the character as prefab in a dialogue action, seems like the _Awake function is not being called.

  • seems like the _Awake function is not being called.

    It won't be, if the character isn't in the scene.

    You mentioned using code earlier - are you making use of a custom script? If so, you should be able to manually update the ID as part of it:

    if (myCharacter.displayLineID == -1) myCharacter.displayLineID = myCharacter.lineID;
    

    Otherwise, it should be possible to update the ActionSpeech file with something similar.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.