1 / 3

Adding Real-time Communication in Unity3D Multiplayer Games

This blog simply talks about how game developers can add real-time communication with AppWarp in their Unity3D games to make them rich and engaging.

shephertz
Download Presentation

Adding Real-time Communication in Unity3D Multiplayer Games

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Adding Real-time Communication in Unity3D Multiplayer Games AppWarp has been here for quite some time now. Thousands of game developers in more than 150 countries have built amazing multiplayer games on multiple platforms using AppWarp. The most consistent and popular of them all remains Unity3D. In this post, I will simply talk about how game developers can add real-time communication in their Unity3D games to make them rich and engaging. Implementation of real-time is no rocket science, there is no server side coding or socket level programming is required—everything including the real-time communication is handled by AppWarp Cloud. Should you need to learn how to get the pieces together and setup the basic code required, here is our tutorial video that has stood against the tests of time and still assists game developers across the world with a sample project we had created. The entire source code of this sample is available in our Git Repo, but I am mentioning some of the relevant code snippets below. Get AppWarp SDK for Unity3D here—to initialize it, simply enter your API and Secret Keys which you will get once you sign up for AppWarp and create your first project. WarpClient.initialize(apiKey,secretKey); Now create and add a Listener which implements the relevant WarpClient callback interfaces and connect with the server. Listener warpLayer = new Listener(); WarpClient.GetInstance().AddConnectionRequestListener(warpLayer);

  2. WarpClient.GetInstance().AddNotificationListener(warpLayer); WarpClient.GetInstance().AddRoomRequestListener(warpLayer); Now simply call connect to establish your connection with the server. WarpClient.GetInstance().Connect(); Once your connection is established and authenticated, simply join a room and subscribe it to receive its notifications. WarpClient.GetInstance().SubscribeRoom(roomid); WarpClient.GetInstance().JoinRoom(roomid); After you have joined the room, you can start sending your user’s coordinates to other users in the room. In this example we will use our chat API to do that string json = "{\"x\":\""+transform.position.x+"\",\"y\":\""+transform.position.y+"\",\"z\":\""+transfo rm.position.z+"\"}"; WarpClient.GetInstance().SendChat(msg); Once the remote player also joins, you will start receiving messages from it. Handle them and move the cylinder representing it publicvoid onChatReceived (ChatEvent eventObj) { Log(eventObj.getSender() + " sent " + eventObj.getMessage()); SimpleJSON.JSONNode msg = SimpleJSON.JSON.Parse(eventObj.getMessage()); if(eventObj.getSender() != id) { appwarp.movePlayer(msg["x"].AsFloat,msg["y"].AsFloat,msg["z"].AsFloat); } } . . . And this is it. Just build your Unity3D app on two different endpoints and you should be able to see two endpoint movements in real time(a simple white cylinder)! Schedule a quick demo if you would like our AppWarp expert to get in touch to walk you through the development process with AppWarp management console.

  3. Also read: Bridging the Gap – Plugin for Unity & iOS Furthermore, AppWarp can always be clubbed with gaming backend APIs that will not only help in user engagement but also will earn you long lasting loyalty. Some of the top use cases that will enable you grow your game are: 1.Implement in-app referrals with our growth hacking toolkit to boost game downloads 2.Enable social sharing of all the moments, levels unlocked or completing any major event 3.Implement social leaderboards to induce competitive spirit and improve user engagement 4.Never lose the interest of your users by launching campaigns on all channels including push, email, and in-app messages 5.Predict the propensity of the players to uninstall the game and send personalized notifications to re-engage them Also read: How to Implement In-App Purchase in Your Game Click here to know all the use cases game developers across the world are implementing to grow their game and drive more conversions. You may, at any point of time, could schedule a demo on how you can enhance user acquisition, engagement, retention, and conversion in your game.

More Related