Skip to content

This is an Unreal Engine game built using the Stack'O'Bot game, a third person sandbox project built by Epic Games to showcase UE 5 features. PubNub has enhanced this functionality by integrating real-time features utilizing PubNub's Unreal SDK.

License

Notifications You must be signed in to change notification settings

oliverfcarson/pubnub-unreal-stackobot

Repository files navigation

PubNub's Enahnced Stack'O'Bot Game with In-Game Chat, Online Presence, and More!

Welcome to PubNub's Stack'O'Bot Game Enahnced with our Unreal SDK! Stack O Bot Game

This is an Unreal Engine game built using the Stack'O'Bot game, a thirdperson sandbox project built by Epic Games to showcase UE 5 features.

PubNub has enhanced this functionality by integrating real-time features utilizing our new Unreal SDK, such as:

  • In-Game Messaging: Send and receive messages in the lobby and main menu.
  • Channels: Communicate with different players through whisper (private), group, and all (public) chat.
  • Presence: Detect when users are online/offline
  • Blueprint Compatible: The Unreal SDK is Blueprint compatable, and the entire chat example was built using Blueprints.

While this README is focused on the PubNub functionality added to the game, please review the learning path from Epic Games to understand the base game itself.

Note:

  • This game is meant to serve as a simple sample of how easy it is to power real-time features using PubNub.
  • The game is actively in development and more features are planned to be incorporated in the near future.

Prerequisites

You'll need to perform the following before getting started. Make sure you follow the Unreal SDK for specific details or updated changes to installation instructions.

Set up Project Enviornment

  1. Download Unreal Engine 5.0 and higher. This project was built wiht 5.4.3.
  2. Clone the content of the Unreal SDK repository into the Plugins folder. Change the sdk folder name to Pubnub.
  3. Generate C++ project files (as we need to add the SDK to the build file) by rick clicking on your .uproject file.
  4. The private module dependency has already been added for you in Source/_{YourProject}_/_{YourProject}_.Build.cs.
  5. Build the solution.
  6. Open the StackOBot.uproject in UE.
  7. Click Edit > Plugins, and ensure the PubNub SDK is enabled.
  8. In the same plugins folder, ensure the JSON Blueprint Utilities Plugin is enabled. It should be by default.
  9. Click Edit > Project Settings and scroll down to the Plugins section and click Pubnub SDK.
  10. Add your publish and subscribe keys obtained in the next step and save. Ensure the Initialize Automatically Checkbox is checked.

Get Your PubNub Keys

  1. Sign in to your PubNub Dashboard. You are now in the Admin Portal.
  2. Click on the generated app and keyset or create your own App and Keyset by giving them a name.
  3. Enable Presence by clicking on the slider to turn it on. A pop-up will require that you enter in “ENABLE”. Enter “ENABLE” in all caps and then press the “Enable” button. Enable the "Generate Leave on TCP FIN or RST checkbox", which generates leave events when clients close their connection (used to track occupancy and remove non-connected clients in app). You can leave the rest of the default settings.
  4. Enable Stream Controller.
  5. Click on save changes.
  6. Save the Pub/Sub Keys.

You are now ready to start playing the game!

Playing the Game

Stack O Bot Playing the game

To begin playing the game, start the game in the editor.

  • The number of currently logged in platers will be displayed at the top of the screen (Presence).
  • You can open the chat with the Enter key on the keyboard. This focuses the chat and darkens the chat elements.
  • Type a message and press the Enter key again to send the message. This display the message to you and everyone else (all = public channel)
  • There are different commands you can trigger in the chat. Enter /help in the chat to pull up these various commands
  • Type /whisper <userId> to establish a private message channel with another player. The text will become green and opens a private messaging channel between you and that associated player - no one else can see these messages.
  • Type /join <groupName> to join a group. The text will become orange and opens a group channel between you and that group after you start to type messages.
  • Type /leave <groupName> to leave the specified group.
  • You can cycle between channels with the Left CNTRL key on the keyboard. Keep in mind you need to have at least one other channel you are associated with before cycling channels.
  • Both the open chat and channel cycling key can be changed to another key or button the gamepad via the Input Mapping Context located in Content > StackOBot > Input > IMC_ThirdPerson. This will also change the text displayed on the screen for what key to press to open or cycle channels.

Files Adjusted

The following files are of focus to review for this game and pertain to PubNub Functionality. All functionality has been built using Blueprints, so please take a look at the Graph view of each Blueprint to examine functionality. Everything is located in the Content > Chat folder. Specific functionality:

  • AC_Chat_PC: Contains initial configuration and some event handling to listen for keyboard input
  • WB_ChatUI: Contains the UI elements, the chat and presence count.
  • WB_ChatBox: Contains the chatbox and most of the logic of the app, including PubNub setup, channel cycling, etc.
  • WB_PresenceCount: Displays the occupancy count

Testing Chat using the Debug Console

In the Admin Portal, there is a Debug Console that allows you to test your PubNub app and keys as another user. You'll need to keep in mind a few details when testing:

  • The channel architecture necessary to subscribe and receive messages as follows:
    • group: group.<groupname>
    • whisper: whisper.<gameUUID>-<AdminPortalUUID>. Since the debug console can't handle logic to understand if the whisper contains that message, you need to always format the channels in this order in the debug console. You can find your gameUUID by simply entering in a message in the game: the publisher is always to the left of the message. Keep in mind for simplicity sake, the UUID changes each time you load the game.
  • Due to the architecture of the Unreal SDK and how the Debug Console sends messages, you need to format the message in JSON format in the Debug Console with the text and publisher fields. An example: {"text":"hi there!","publisher":"amy"}

Links

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

This is an Unreal Engine game built using the Stack'O'Bot game, a third person sandbox project built by Epic Games to showcase UE 5 features. PubNub has enhanced this functionality by integrating real-time features utilizing PubNub's Unreal SDK.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published