- Home /
Subtitles in fps game
Hey guys! I'm making a fps games and I want to have subtitles in it. Like player hits a cube trigger, the the guide subtitle gui comes up at the bottom of the screen, with an audio. The after the audio is done, (example-15 seconds) the gui disappears. Please help, I'm still new to unity, and very, very, very very new to coding.
Thanks!
I strongly recommend using 2DToolkit for "type in Unity".
It's like this ..
1) install 2DToolkit
2) click the "text mesh" button and text appears in your scene
3) move it around, or whatever, like anything else in unity. it's "just that simple".
4) in the code, type more or less "text = "whatever 999"" and the text changes to your new text.
It's the only reasonable way to do score displays, alerts, subtitles -- anything.
It's also utterly essential simply for messages to yourself during development, and so on.
It's really the only way to do type in games in Unity. For many, many popular games now we have converted clients to just using it. It's so, so simple, efficient, etc. You're not trying to ludicrously build mesh around the type edges each time etc. It's just the only way to go.
There's a long comment here ...
http://answers.unity3d.com/questions/384623/setting-font-size-according-to-screen-dpi.html
where I explain precisely how to use "GlyphDesigner" which is the easiest possible way to use any font, whatsoever, in 2DToolkit and hence in Unity.
Couldn't be easier. We tried every possible pipeline before settling on this.
i like fattys idea, but i dont want to pay that much. id rather not pay for anything at all. i looked at the links you posted, but its just audio. i really need the subtitles. i researched everywhere but no, i need help.
The GUI part I posted is your subtitle. You use GUI.Label to show text on screen. In my example, you're checking if the audio is playing or not in order to deter$$anonymous$$e if the GUI Label should show on screen.
For free .. just use the crapp GUI system part of Unity - it works fine!
Answer by clunk47 · Sep 21, 2013 at 05:18 PM
A simple solution, check out AudioSource.isPlaying. This isn't a script you can actually use, it's an example of what you would have inside a C# class, because you didn't specify which language you prefer. Break down the example and google each part you don't understand. Also look at the Unity Script Reference that I've linked you to with the information on AudioSource.isPlaying.
bool showSubs;
string sub = "This is a subtitle. Audio is Playing.";
void Update()
{
if(audio.isPlaying)
showSubs = true;
else
showSubs = false;
}
void OnGUI()
{
if(showSubs)
GUI.Label(new Rect(0, Screen.height - 64, Screen.width, 64), sub);
}
Answer by YoungDeveloper · Sep 21, 2013 at 06:22 PM
Create new class inside main class, in that class add string, for subtittle text, one float for start time and second for end time. Set everything public. Then create an array of these classes, without setting constant array size. So now you have a dynamic array, and for each element you can set text, start and end time.
Create ongui function, create a text area or whatever and position the area where the subtitle text will be.
Create a variable wich will hold time for subtitles. Something like a = Time.deltaTime.
Then somehow create a little system wich sends string from array element to ongui function to show it on screen depending on elements start and end time. I would need to draw a diagram on paper and think a bit about it, but I'll leave something for you ;).
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to display Gui for Ammo and ammo left 0 Answers
Question about fliping a character 1 Answer
Scene Selection 1 Answer
Why doesn't my GUI.Label show up? 1 Answer