- Home /
Can I make a choice-driven game?
I'm planning on making a Mass Effect-esque game (a small version, at least) and I want to know how I can (if I can) make the player choose between two or three texts, and then something different happens, maybe one is an answer and another triggers a fight. I want to do it on my own so I can learn, so just say how to do it or write a few commands, not a script, please. I use javascript. Thanks!
Right now you are at a design stage, so you question might be better asked on Unity Forums. There are three built-in ways to do text in Unity:
GUI: text can be put in a GUI.Button() or you can use a GUI.Label() and use Rect.Contains() to detect a click on the text.
GUIText: On$$anonymous$$ouseDown works with GUIText or you can GUIText.HitText() to detect a click by the mouse.
3D Text/Text $$anonymous$$esh: you must put a collider (usually a box) on the text. Then you can use On$$anonymous$$ouseDown() or Raycasting() to detect a click on the text.
Answer by getyour411 · May 26, 2014 at 04:49 AM
if(GUI.Button(...),choice1)) {
// start fight
}
if(GUI.Button(...),choice2)) {
// give witty answer
}
Answer by Midnaut · May 26, 2014 at 06:21 AM
To answer the design part of the question,
you'll probably want to make some kind of conversation manager. For a mass effect style, you'll need to store camera positions, set up some animation controllers and work out some radial UI stuff.
To get the kind of code structure, for something simple, that doesn't require some kind of graph editor to map the conversation, i'm going to assume that each conversation will consist of a statement, or question, and you will have two choices, one will be the passive response the other the aggressive.
var question;
var choice1;
var choice2;
var talking = false;
function StartConv()
{
talking = true;
}
function OnGUI()
{
if(talking)
{
GUI.label(Rect(10, 10, 200, 50), question);
if (GUI.Button(Rect(10, 100, 200, 50), choice1))
{
AggressiveResult();
talking = false;
}
if (GUI.Button(Rect(100, 160, 200, 50), choice2))
{
PassiveResult();
talking = false;
}
}
}
function AggressiveResult()
{
...
}
function PassiveResult()
{
...
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613145907im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
I need help fixing this code 1 Answer
Is there Another Alternative to Create your own game easily without Coding? 1 Answer
what is the best way to do this game? 2 Answers
Pathfinding for RPG games 2 Answers
WHY SAYS ME THAT IS AN ERROR? 1 Answer