- Home /
Multiplayer|3dText PlayerName
I have a player prefab, that have playername variable. i want to "attach" the name of the player to 3dtext object that attached to the player prefab, and the "text" blank will be equal to the playername variable.
Are you using C# or Javascript ? can you attach your code?
@utoyo:
Don't post this as answer. I've converted it into a comment.
You have the 3dtext object, right? Then in it's Start()
method or whatever method you use for initializing your players, you can just access it's text
property and set it to the player's name, presu$$anonymous$$g you passed it via RPC
beforehand.
i'm using JS. okay-again, i have the player prefab, then, i have in the prefab 3dtext object named "playername", and in the scense i have game object named "DirectConnectGUI" with a "connectionGUI" script. to the "connectionGUI" script, i add variable named "playername". and now i can't drag the 3dtext object (the playername object) that placed in the player prefab, to variable "playername" that placed in "DirectConnectGUI" gameobject with a "connectionGUI" script, i can't attaching it..
what kind of variable it is ? Playername and 3dtext....You declared them as a GameObject or GUIText in the "connnectionGUI" script??
Answer by ScroodgeM · Aug 08, 2012 at 10:34 PM
//this should be your existing line with player name stored public string MyName; //add this line to same script where name stored and attach 3d text to this in inspector public TextMesh Text3D; void Start() { //now this applies player name to 3d text. once. if you need to do it more times - repeat this line wherever you need. Text3D.text = MyName; }
i got this error:
The name 'Text3D' does not denote a valid type ('not found').
from this line:
var playername : Text3D;
Text3D here is a variable, you should use Text$$anonymous$$esh ins$$anonymous$$d
work's, but i got little problem: when i open two exe game files on the same computer (my computer), and the first player choose his name:"player1" and the second player choose his name:"player2". the problem is that when the first player spawned (connected) to the game, his name is really "player1", but when the second player spawned (connected) to the gme, the name of those both player's are "player2"! WHY?!
don't publish comments as answers.
telepaths are on holiday. in your great description "doesn't works" i can't figure out an issue and resolve it.