That’s Not My Name: Beginning and progressing

For the past several days, I have been developing ‘That’s Not My Name’ as previously mentioned in my Studio 2 Introduction Diary, a project about being referred to something that you’re not or you’d prefer not to be.

The project is inspired by the visual style of JRPG games with the menu’s and world movement being similar to that of the Pokémon franchise. The project is essentially a walking simulator where you input your first, preferred and last name and every character will refer to you as your first or last name, forcing the screen to shake until the final NPC apologises and refers to you by your preferred name. The idea was to show how annoying it is to be called the wrong name and how tedious and can be having to repeat what you want to be called over and over again.

Keyboard from project

The prototype for the keyboard was the first new thing that I created and haven’t attempted before in Unity. I had to learn about the Unity layout grids as well as implement a lot of tedious keyboard inputs as the player movement as the player cannot actually type or click the onscreen keyboard, similar to that of the earlier JRPG videogames.

Below is the script for the entire keyboard script;

public class KeyboardInputField : MonoBehaviour {
public static KeyboardInputField Instance;
//String name variables
public string FirstName;
public string MiddleName;
public string LastName;
//Text for inputfields (as a variable)
public Text InputField;
public Text PlayerName;
//Variables for name prompts
public Text NamePrompt;
public GameObject NamePromptObject;
//Variable to keep track of first, second and last name
public int NameSelection = 0;
//Keeps track of initial name input and repetitive inputs
public bool InitalInput;
public string RepeatFirstName;
public string RepeatPreferredName;
public string RepeatLastName;
// Use this for initialization
void Awake ()
{
Instance = this;
InitalInput = true;
RepeatFirstName = PlayerPrefs.GetString(“First Name”);
RepeatPreferredName = PlayerPrefs.GetString(“Middle Name”);
RepeatLastName = PlayerPrefs.GetString(“Last Name”);
}

// Update is called once per frame
void Update ()
{
PlayerName.text = “My name is “ + FirstName + “ “ + MiddleName + “ “ + LastName;
TextPrompt();
PlayerNamePreview();
}
public void PlayerNamePreview()
{
if (InitalInput == true)
{
PlayerName.text = “My name is “ + FirstName + “ “ + MiddleName + “ “ + LastName;
}
if (InitalInput == false)
{
PlayerName.text = “Yeah, my name is “ + RepeatFirstName + “ but I’d prefer to go by” + MiddleName;
}
}
public void NameFields()
{
print(“lol”);
}
public void NameField()
{
//Initial Name Input
if (InitalInput == true)
{
// NameSelection = 0;
if (NameSelection == 1)
{
NamePrompt.text = “Middle or Preferred Name…”;//Easier to put this here than fix it (should be selection 2)
if (InputField.text == “”)
{
NameSelection -= 1;
}
else
{
FirstName = InputField.text;
InputField.text = “”;
PlayerPrefs.SetString(“First Name”, FirstName);
}
}
if (NameSelection == 2)
{
NamePrompt.text = “Last Name…”;//Easier to put this here than fix it (should be selection 3)
if (InputField.text == “”)
{
NameSelection -= 1;
}
else
{
MiddleName = InputField.text;
InputField.text = “”;
PlayerPrefs.SetString(“Middle Name”, MiddleName);
}
}
if (NameSelection == 3)
{
NamePrompt.text = “Please Confirm Your Selection…”;
if (InputField.text == “”)
{
NameSelection -= 1;
}
else
{
LastName = InputField.text;
InputField.text = “”;
PlayerPrefs.SetString(“Last Name”, LastName);
}
}
}
/*
//Secondary Name Input
if (InitalInput == false)
{
NameSelection = 0;
FirstName = RepeatFirstName;
LastName = RepeatLastName;
if (NameSelection == 0)
{
NamePrompt.text = “Middle or Preferred Name…”;//Easier to put this here than fix it (should be selection 2)
if (InputField.text == “”)
{
NameSelection -= 1;
}
else
{
FirstName = InputField.text;
InputField.text = “”;

}
}
}
*/
}
public void TextPrompt()
{

if (InputField.text.Length == 0)
{
NamePromptObject.SetActive(true);
}
else
{
NamePromptObject.SetActive(false);
}
}
public void UpdateInputField(string input)
{
if (input == “Backspace”)
{
InputField.text = InputField.text.Substring(0, InputField.text.Length — 1);
}
else
{
InputField.text += input;
}
}
}

I will admit that there are a lot of public variables that are simply not needed within this. However, other scripts were being references and the variables being public was necessary for the keyboard. Below is the codeblock that registers and acts as a multiscript constructor

public class KeyScript : MonoBehaviour {
public static KeyScript Instance;
public int NamePosition;
public void Awake()
{
Instance = this;
}
public void KeyClicked()
{
KeyboardInputField.Instance.UpdateInputField(gameObject.name);
}
public void BackspaceClicked()
{
KeyboardInputField.Instance.UpdateInputField(gameObject.name);
}
public void ContinueClicked()
{
KeyboardInputField.Instance.NameSelection += 1;
KeyboardInputField.Instance.NameField();
KeyboardInputField.Instance.NameFields();
}
public void ConfirmSelection()
{
if (NamePosition == 3)
{
Application.LoadLevel(“World”);
}
}
public void Update()
{
NamePosition = KeyboardInputField.Instance.NameSelection;
}
}

In both scripts, I have Public Static SCRIPTNAME Instance; and by doing this as well as Instance = this; within Awake() , I can manipulate variables and initiate classes by doing SCRIPTNAME.Instance.VARIABLENAME in a given instance.

Honestly, in the past week, the most advanced thing that I have completed that I have yet to do in a previous project is the on-screen keyboard and how tedious it was attaching the script to every single key. In the future, I will definitely make utilise prefabs better to avoid such tedious tasks and hopefully next week, I won’t make the same mistake with similar tasks.