LogoLogo
What's New?API StatusOur Website
  • Morpheus Platform Documentation
  • What is Morpheus Platform?
    • Glossary
    • Interoperability
    • Support
    • EULA
  • Firewall Problems
  • CREATION
    • Unreal Development
      • Get Started
        • Download the Editor
        • Upload Content
        • Creating your Own Map
        • Morpheus Base Project
        • Differences from Unreal
          • Character Configuration
        • Morpheus Networking
          • Introduction to Morpheus Networking
          • Network Levels
          • Replicated Properties
          • RPCs
          • Morpheus Render Targets
          • Morpheus Array
          • Networking FAQ
          • Replicating Sublevels
      • Editor Versions
      • Performance Guarantees
      • Features & Guides
        • Example Plugin
          • Nameplates
          • In-Game Roles
          • Resizing
        • Actor Pooling
        • Audio
        • Avatars
          • Creating an Avatar
          • Attachments
            • MML Attachments
          • Custom Animation Variables
          • Importing an NFT Collection
          • Capsules and Mesh Transforms
        • Bots
        • Chat
          • Unreal Text Chat
        • Control Panels
          • Control Panel Configuration
          • DJ Booth Mission Control
          • Observer Controls
        • Crowd Audio
          • CrowdAudioComponent advanced configuration
        • Crowd Rendering
          • Legacy Animated Crowd
            • Animated Crowd Console Commands
            • Attaching static meshes to crowd members
          • Crowd Materials
          • Performance Parameters
          • Live Config Settings
          • Crowd Animation
            • Crowd Anim Blueprint
              • User Guide - Crowd Anim Blueprint
              • Reference Guide - ABP Nodes
                • Animation Playback
                • States and State Machines
                • Variables
                • Transitions
                • Special
                • Blends
                • Additional Notes
        • Helpers & Extras
          • "Instanced Objects" in Blueprints
          • Objects with "world context"
          • Making DataAsset classes
          • Duplicate Objects
          • The Bootflow Subsystem
          • The "Wait For Condition" System
          • Advanced Graphics Settings
          • Listening to Inputs on UObjects
          • Morpheus UserID
          • World Services
          • M2Extras: Skins System
        • Loading Screen
        • Live Config
          • Editing for a World
          • Editing Locally
          • Default Settings
          • Accessing via Blueprint
          • Adding New Settings
          • Overriding Defaults
          • Using Arrays
        • MML
        • Motion Capture
        • Networking
        • Notifications
        • Raycastable Crowd
        • Singletons
        • Streaming & Multiplatform
          • GFN on Mobile
        • UI
          • "UI Mode"
        • Video Players
          • Embedded Video Player
          • Millicast video streaming
            • How to Setup an In-Game Video Stream
            • Picture-in-Picture mode
          • Streaming Video Player
            • How to Setup a URL Video Player
            • Picture-in-Picture mode
        • Visual Debugging
          • Inspector
        • Online Services
          • KV Store Service
        • Web Browser
          • Setup the browser widget
          • Viewport browser
          • In-world browser
          • Loading embedded pages
          • Game <--> Browser Communication
          • Debugging issues
        • Web Requests
          • Http Requests
            • Legacy HTTP Nodes
          • JSON Handling
          • WebSockets
          • Identity Validation
          • Allowed External URLs
          • Walkthrough Example
            • Example Counter Service
        • World Travel
          • World Travel in the Editor
        • Avatar Physics Assets
        • Action Gameplay Helper Components
      • Workflows
        • Upgrade the Editor
        • Editing Project Settings
        • Profiling
        • Marketplace Importing
        • Extra Workflows
          • Setup Play-in-Editor
          • Setup Local Asset Validation
          • Adding Gameplay Tags
          • Validating Game Assets
          • Custom Connection Modes
          • Connect Editor to a World
          • Common Issues
      • Best Practices
    • Worlds
      • Invite Players
        • Setting Role Groups
      • Persistent Worlds
      • Always on Worlds
    • Running Events
      • Large Scale Events - Checklist
      • Anti-Cheat (EAC)
      • Player Entry
        • React Native
        • Steam
        • Hardware Requirements
      • Broadcast
        • OBS Integration
      • Failover
      • Capacity and Queue Management
  • ADMINS
    • Access Control
      • Add Metaverse Contributors
      • Create a New Project
    • Pricing
      • Development Support
      • Included Usage & Overages
      • Cloud Streaming
      • Access Modes
      • War Room Support
      • Platform SLA
    • Settings
      • Projects
  • APIs and Tooling
    • API Reference
      • Accounts
      • Events
      • Key/Value Store
      • Organizations
      • Realtime
      • User Profile
      • World Builder
      • Worlds
    • Template Web App
      • Moderation
    • Pixel Streaming
    • Launcher
  • Dashboard
    • Assets
      • Assets Versions
      • Engine Plugins
      • Project Plugins
      • Templates
    • Releases
  • Integrations
    • Analytics
      • Send Events from Web
      • Send Events from Unreal
    • Chat
      • Integrate Pubnub with your Unreal Project
      • Add Moderation to Chat
Powered by GitBook
On this page
  • Introduction
  • Setting up Pubnub in your Editor
  • Retrieving your Keys
  • Pubnub APIs
  • Important Blueprints
  • Modifying the TextChatComponent Blueprint
  • Modifying the TextChatComponent Blueprint to use your own Pubnub app

Was this helpful?

  1. Integrations
  2. Chat

Integrate Pubnub with your Unreal Project

A simple way to integrate your Pubnub app with your in-game chat

PreviousChatNextAdd Moderation to Chat

Last updated 3 months ago

Was this helpful?

Introduction

To connect Pubnub to your in-game experience, you can make use of Pubnub's Publish, Subscribe, and History functionality to send, receive and list all messages sent to specific channels.

This can be done in both:

  1. Your Unreal Project by making use of Pubnub's APIs.

  2. Your web application using

This guide covers setting up Pubnub to work within your Unreal project.

For information on setting up Pubnub in a web project, we recommend checking out Pubnub's own documentation on their and , as well as how to and to messages via their APIs.

Setting up Pubnub in your Editor

Retrieving your Keys

When creating your Pubnub application and keyset, you will find that each keyset has a Publish, Subscribe, and Secret Key associated with it. For the purposes of implementing Pubnub chat in your project, you will need to note down your Publish and Subscribe key, as these will be used as part of the API requests.

In addition to needing these keys, every request made must be associated with a Pubnub Channel. There is no special set-up required to create a new channel - they are created automatically when providing a value for channel name in any of the API calls.

Pubnub APIs

We will be making use of 3 key APIs as part of integrating pubnub with the in-game chat component:

  1. Publish API (POST):

    1. https://ps.pndsn.com/publish/{my-pub-key}/{my-sub-key}/0/{my-channel-name}/0?uuid={my-unique-id}&auth={my-auth-token}

  2. Subscribe API (GET):

    1. https://ps.pndsn.com/v2/subscribe/{my-sub-key}/{my-channel-name}/0?uuid={my-unique-id}&tt={my-time-token}&tr={my-region}&auth={my-auth-token}

  3. History API (GET):

    1. https://ps.pndsn.com/v3/history/sub-key/{my-sub-key}/channel/{my-channel-name}?include_message_type=true&include_uuid=true&include_meta=true&max=100&uuid={my-unique-id}&auth={my-auth-token}

Important Blueprints

There are 2 blueprints that will aid you in implementing Pubnub supported chat:

  1. BPMC_TextChatComponent : this is where all of your changes to integrate Pubnub will live (specifically, on MorpheusBeginPlay ).

  2. BP_M2_PubnubConnection : this is a helper blueprint that handles the construction of the pubnub API urls, and handles the sending of all requests. We recommend looking through this blueprint, as well as the TextChatcomponent, to get an understanding of how both blueprints work together to retrieve data from Pubnub and display it in the text chat widget.

Modifying the TextChatComponent Blueprint

Currently, the chat widget you see in a game is controlled by the blueprint BPMC_TextChatComponent. You will need to:

  1. Make a copy of this blueprint.

  2. Modify the copy, adding the below changes.

    1. Go to the event graph, and on Event Morpheus Begin Play, remove all nodes after the below comment block:

    2. Next, add some variables (categorised under Pubnub) to the blueprint: here, we will store the Publish Key, Subscribe Key, and a Default Channel Name.

Modifying the TextChatComponent Blueprint to use your own Pubnub app

  1. Instead of using the Social World Service (which handled retrieving the sub/pub/auth keys), we are instead going to make direct use of the Handle Fetch Chat Auth Response function pre-provided in this component.

  2. The example uses the Subscribe Key and Publish Key (and optionally and auth token), and passes this into our Pubnub helper blueprint BP_M2_PubnubConnection , which is where all publish, subscribe and history requests are formatted and sent.

    1. The channel name as mentioned above can be defined as anything you like. When initialising the Channel Name variable, ensure you give it a default value so that in cases where world/launch context id does not exist, your chat will still be sent to your default channel.

    2. You can use any unique identifier for channel name; for example, you can use our helper node Get M2 Web Platform World ID to retrieve the world's unique id. This will ensure that each launched world will use a separate Pubnub chat channel, so messages are properly gated.

The above method requires exposing publish and subscribe keys in editor. Whilst this won't be exposed to players, you may want to obfuscate these with a more robust handling of your pubnub keys.

A recommended approach would be to integrate the returning of keys with an existing/new web service. Pub, sub, and auth tokens can then be returns via an API call from this service, and used directly instead of the blueprint variables above. This could all be handled via an intermediary blueprint (similar to the M2 Social World Service).

Once you've completed the above steps you will also need to copy/change references in any other blueprints using this component.

If everything is set up correctly, you should be able to send messages using the chat widget in PIE as before, and the history of the chat should be shown in the in-game chat!

Pubnub's documented SDKs
chat SDKs
core SDKs
publish
subscribe