PNMS Basics
In this series we will go over how you can get up and running with the PNMS system. The PNMS has two demos you can download for free and use. They are built using plugins so that it is easier for you to bring them over into a new project and have a starting point.
The Guides
The focus on these guides is to provide you with a core understanding of how the PNMS is implemented for performing Mounting, Dismounting, and Seat Changing. The Demo project is meant to augment this knowledge by showing you how the PNM System is fully implemented in either A simple manner or an advanced manner for a project.
The Demo encapsulates the two implementations into Plugins so you can copy the plugins from the Demo and drop them directly into your plugins folder for your project so for easier implementation.
Requirements
In order to implement the PNMS system you will need to have the following things. If you are working on your own project you probably have most of these, but if not there are some suggestions.
The Rider
The rider is any Pawn or Character that you want to attach or ride on one of your Mounts or Vehicles. Generally you can use the Manny or Quinn from the Unreal Engine 3rd Person Template project as your Rider.
The Mount
The mount can be any Actor, Pawn, or Character that you want to be either a seat, a Mount, or a Vehicle in your game. The PNMS system uses Unreal Engine's Possession Logic to control mounts that can be moved. This means that if you want a player or AI Agent to control a mount then it needs to have a base class of a Pawn, Character, or WheeledVehicle which allow possession. Otherwise you will need to write your own custom logic for controlling non-Pawn actors.
Getting a mount for this one is a bit more difficult. There are free assets on the Unreal Engine Market Place that you can download that could be used as a Mount. Many of the Paragon assets as well as well as the Infinity Blade Adversaries content. Alternatively you can create a mount based on Unreal Engine's two Mannequins.
The Controller
Weather you are working with a Player or an AI Character they both need a Controller to start the processes of the Mounting System. All Mounting, Dismounting, and Seat Changing Operations occur at the controller level. For players you will need a PlayerController while for AI characters you will need an AI Controller.
The Map
You will need a map to play on as we build the system. Generally I start with the 3rd person template and create a duplicate of the ThirdPersonMap.
Sitting Animations
Finally you may want a sitting animation to capture the complete effect. You can do this tutorial series with out a sitting animation but it will look odd, but functionally it will work fine.
Obtaining a sitting animation will be up to you as it is technically optional. You can try to create one using Unreal Engine's built in animation tools as well or use Blender.
Mounting System Tutorial (MST) Plugins
The Mounting System Tutorial Core and Mounting System Tutorial (MST) Plugins both make up a demonstration of the barebones implementation of the Mounting System. Though they are plugins they are Blueprint only plugins with no C++ code for demonstrating how to implement the PNMS in blueprints. The two are separated into separated Plugins specifically to allow you to drop them into your project easier.
Mounting System Tutorial Core
The MST Core implements the mounting system in Blueprint and is also are barebones implementation. None of the Bueprint classes provide any visual or artistic representations. The goal of this plugin was to provide a barebones foundation to easily leverage into your game without any art and asset dependencies. This should allow you to drop the plugin into your plugins folder of your project and with a bit of reparenting you can have functional mounting system.
This plugin Provides
- MST Player Controller Base - with properly implemented Interfaces and RiderComponent
- Inputs - Uses Unreal Engine's Enhanced Input
- MST Character Base - implements the core functionalities and movement of a character for both Riders and Mounts based on Characters
- MST Rider - Implements the proper Interfaces and MountRiderComponent that define a Rider in the system
- MST Mount - Implements the proper Interfaces and MountablePawnComponent that defines a Mount
Mounting System Tutorial
This plugin picks up from where the MST Core leaves off. It provides:
- MST Player Controller - Child of the Core PlayerController. Implements the Basic Interaction System and Interfaces that are responsible for triggering interacitons through input.
- MST Character - child of the Core Rider. This blueprint simply provides visual context to the Rider
- MST Robot Horse - Child of the Core Mount. This blueprint provides visual context to the mount but also provides definition of the seating available on the mount.
- MST Game Mode - A basic child of GameMode with the MST Character and MST Player Controller set as its defaults.
- Interaction UI - some UI elements that enhance the Robot Horse to hide or show when the player can interact with it.
- A Map to test in with the Mount placed in it
Advanced Mounting System Plugin
The Advanced Mounting System plugin is a standalone plugin that implements a fully featured implementation of the PNM System in C++. It still everages the Basic Interaction system blueprint plugin but everything else is implemented in C++. Additionally this also allows the AMS to be copied and pasted into your project's Plugins and used as a base class for your own game.
Core Components
The core components are a high level overview of how the Interfaces and Components that make up the PNM System.
IADMUnifiedControllerPawn Interface
The IADMUnifiedControllerPawn Interface is implemented on all three core objects which are the Controller, the Rider, and the Mount. This interface allows the Controller, the Rider, and the Mount to retrieve each other without confusion. The Controller takes possession of the Mount, which means functions like AController::GetControlledPawn() will get the Mount and not the Rider. It also allows external systems such as an interaction system or an animation system to retrieve the correct Rider or Mount to sync animations between them.
Rider Controller Components
A Rider Controller can be either a PlayerController or an AIController that you want its Controlled Pawns to be able to Mount an Animal Mount or Vehicle. All Rider Controllers implement the IADMUnifiedControllerPawn Interface but also implement the IRiderControllerComponent and have a RiderControllerComponent
IRiderControllerInterface
This interface represents the public facing functionalities that external classes can leverage to begin various PNM System operaitons such as Mounting, Dismounting, and Seat Changing. Generally the three major operations of the mounting system begin with the Controller which then orchestrates the process between the Rider and the Mount.
RiderControllerComponent
This component encapsulates all the settings and functionalities needed to implement the IRiderControllerInterface functionalities. Many of these functions map directly to the IRiderControllerInterface, but some are explicitly design for customization purposes and hooks for handeling errors you may encounter.
Rider Components
A Rider can be either a player's character or an AI Entity or Charcter that you want to be able to Mount an Animal Mount or Vehicle.
IMountRiderInterface
This interface represents the public facing functionalities of a rider that external classes such as a controller or mount can leverage to interact with a Rider such as fetching what seat it is attached.
MountRiderComponent
This component encapulsates all the settings and functionalities that need to be implemented by the IMountRiderInterface as well as defines various attachment and possession behaviors of the rider. Many of these functions map directly to the IMountRiderInterface for easy implementation, but some are explicitly designed for as customization points and hooks for things like moving into place or playing animations.
Mount Components
A Mount can be any Actor, Pawn, or Character that you wish your Rider to be attached to as if they where riding and/or controlling the mount.
IMountablePawnInterface
This interface represents the public facing functionalties of the mount that external objects such as a controller or rider can use to interact with the Mount.
The term "Pawn" is now a misnomer for this system. Originally only Pawns could be used as the base class for a mount due to their ability to be possessed, but as the system became more flexible the PNM System could be used to attach to any Actor and not just Pawn or Character base classes.
MountablePawnComponent
This component encapsulates all the settings and functionalities that need to be implemented by the IMountablePawnInterface as well as defines seating configuration for the Mount itself. Many of these funcitons map directly to the IMountablePawnInterface for easy implementaiton but some are explicitly designed for customization points.
Just as the Interface, the term "Pawn" is a misnomer for this system as it can be applied to any Actor you wish to have your Rider sit on and not just a Pawn or Character. Note that only Pawn based classes can be possessed and controlled without additional programming from your team.
Other Considerations
There are some considerations you may want to think about as you are implementing the PNM System in your own game. If you are using the Plugins Demos with Content than many of these considerations are handled for you already. But they may not be exaclty what you want for your game's behavior.
Collision Settings
When beginning a game with Unreal Engine you should always be considering from the beginning what your game's Collision Settings are going to look like. This describes how actors interact with each other through Physics within the game. Unreal has many predefined collision settings already setup for you that work great. However, when it comes to a Mounting System you now need to consider things such as the Rider, the Mount, and the Game Camera colliding with each other. When two attached actors are also colliding with each other this creates the "Runaway-Flying-Vehicle" issue you see in a lot of video games that glitch out.
One of the main things you will want to think about is what kind of collision do you want between the rider and the mount. You could completely turn off collision from the rider while they are mounted. Alternatively you could configure specific collision settings and/or collision object types for the Rider and Mount so that they do not interfear with each other but other objects can. For more on Dealing with Collison in your game see Unreal Engine's Documentation on Collision.
Next Section: Controllers