Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

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,329
    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:
    217
    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.