Page 1 of 1

Hashtable Add question

Posted: 08 May 2009, 15:06
by matrix211v1
Hello All!

I am trying to add a Vector3 using the HashTable.Add, such as this:

Code: Select all

String ColorChoice;
String CharacterType;
String CharacterName;
Vector3 CharacterLocation;

client = GetClient();
Hashtable myHashtable = new Hashtable();
myHashtable.Add("ColorChoice", ColorChoice);
myHashtable.Add("CharacterType", CharacterType);
myHashtable.Add("CharacterName", CharacterName);
myHashtable.Add("Pos", CharacterLocation);

The first 3 will go into the SetUserVariables just fine, but the Vector3 won't. I have also tried to break up the Vector3 as string but I was not allowed to convert Vector3 to a String such as:

String xPos = (String)CharacterLocation.x;


String xPos = (String)CharacterLocation[0];

It's simple. I just need to store the player spawnpoint in the SetUserVariables. Anything I am over looking?


Posted: 08 May 2009, 21:32
by ThomasLund
Dont think you can cast a float to string that way in C#.

float.Parse(CharacterLocation.x) should do it (frsh from memory without a compiler to check syntax)

Argh - its the other way around - a bit easier


Might need to do some fiddling with the globalization settings due to a bug in the mono version that Unity uses though.



Posted: 08 May 2009, 21:34
by matrix211v1
I belived I tried that (float.Parse(CharacterLocation.x) but I don't think Unity liked it.

Posted: 09 May 2009, 06:57
by ThomasLund

See my edit :-)

(I saw on the date stamp that my edit came after your posting)