How to make an Array of Characters

How do you make an array of characters in java script because " and ’ both refer to a string so saying:

var idk : char[] = ['h', 'e', 'l', 'l', 'o'];

doesn’t work because it’s an array of strings not characters. So how do I make an array of characters?

3 Answers

3

That’s a limitation of Unityscript (Javascript). In C# it would work since 'h' is a char in C#. In Unityscript you have to use the workaround to define char-literals:

var idk : char[] = ["h"[0], "e"[0], "l"[0], "l"[0], "o"[0]];

That should work, but haven’t tested it. I don’t use Unityscript…

Make a string, then convert it to a char array:

var blah = "Blah!";
var chars = blah.ToCharArray();

Here, I am sharing how I solved the char array problem… it is in c sharp script. Hope this video can help you guys…

[array for char / character - video][1]

Here is the example of make char array…

public char[] keyword = new char[30];
	public Text mytext = null;
	public string myword =null;
	// Use this for initialization
	void Start () {
		keyword[0] ='a';
		keyword[1] ='b';
		keyword[2] ='c';
		
		for(int i=0;i<3;i++){
			myword = myword+ keyword *.ToString () ;*

I like the dead zone idea! If I ever run into a scenario where I absolutely cannot have any camera movement upon player rotation, I will probably try that out.