How do I add NPCs?

I want to put an NPC (Non playable character) In the game.


  • I want to be able to click on the NPC
Function OnMouseClick() {


  • Have a GUI that pops up to chat

  • Be able to exit the GUI

Can anyone help me :-P

For clicking on an object (that has a collider), look at OnMouseDown(). For the 'chat' interface, look into Unity's built-in GUI system (that's not the only way it can be done, but it's probably the most straightforward way).

Beyond that, I think you'll have better luck if you ask more specific questions (either here or on the forums).

What you could do, is this. This is in C# since I don’t know how to use JavaScript but it shouldn’t be too hard to convert to JavaScript.

bool openChat = false;

void OnMouseClick() {
    openChat = true;
void OnGUI() {
    if(openChat == true) {
        //GUI Code here.