Search Unity

How to make a online chat

Discussion in 'Connected Games' started by Vesnushkin_inc, Oct 10, 2017.

  1. Vesnushkin_inc

    Vesnushkin_inc

    Joined:
    Oct 10, 2017
    Posts:
    1
    You know games like clash of clans and king of thieves and more have a chat we’re uou can talk to guild/ clan members? If you know it would help a ton, or if there is a tutorial on how to make it can someon gimme the link?
     
  2. MiladZarrin1

    MiladZarrin1

    Joined:
    Jul 7, 2013
    Posts:
    74
    Photon Unity Networking (https://www.photonengine.com/en/PUN) offers a real time chat system. You can also make it using UNet (https://blogs.unity3d.com/2014/05/12/announcing-unet-new-unity-multiplayer-technology/) or any other real time networking systems for unity. They offer a lot of features that you may or may not need. They are also a little pricey.
    Or you can make it from scratch using node js (https://whackcode.wordpress.com/2013/09/19/unity3d-talking-to-node-js/) or probably other programming languages. But it is very time consuming.
    It's up to you to choose the best solution for your project.
     
  3. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,405
    It's really quite simple to do with Photon, I did it before.

    In Photon, just have a text box for the UI, and send RPC's back and forth with the message, done.

    E.G.

    Code (CSharp):
    1. using UnityEngine.UI;
    2.  
    3. PhotonView myView;
    4. string chatRoomText;
    5. public Text chatText; // Give a reference to the TextUI where the chatroom Text is at.
    6.  
    7.  
    8. if(myView.isMine){
    9. string messageToSend = "Hello";
    10. myView.RPC("MethodName", PhotonTargets.AllBuffered,0, messageToSend);
    11. }
    12.  
    13.  
    14. [PunRPC]
    15. void MethodName(string newMessage){
    16. chatRoomText = chatroomText + newMessage;
    17. chatText.text = chatRoomText;
    18. }
    Also the "0" after AllBuffered may not be needed, I think it should be there, I just forgot, it will either need to be there or not.
     
    Last edited: Oct 13, 2017
  4. hlw

    hlw

    Joined:
    Aug 12, 2017
    Posts:
    216
    There are also ways to do it using an IRC channel.
     
  5. NinjaPigStudios

    NinjaPigStudios

    Joined:
    Jan 23, 2013
    Posts:
    2
    Checkout http://unity.chat for a pretty easy tutorial on how to make a chat application yourself. Hope this helps.