Controllers
The Controller is where the start of all Mounting Operations begin. If you need the player to start mounting or entering, dismount or exit, or change seats all the operations begin at the controller level for both Players and AI.
References
For a more comprehensive demonstration of how the interfaces and components are implemented for the controllers, download the Demo Projects and inspect the following Classes listed below. Additionally these plugins are designed to be dropped into your project as they are and form a basis for your implementation if you just want to get started quickly. To Download the Demos see Quick Start Guide
Mounting System Tutorial Core (MSTC)
BP_MST_PlayerControllerBase
This blueprint is the generic implementation for Player Controllers. Implementing the components and the interfaces needed to coordinate with the PNM System. It does implement two input functions for Changing Seats to the Driver Seat and the Passenger Seat.
Mounting System Tutorial (MST)
BP_MST_PlayerController
This is a child class of the BP_MST_PlayerControllerBase
. This controller does not add anything for the mounting system but instead implements the Asadeus Studios Tools Interaction Component. The Interaction Component is a prototyping tool that triggers the mounting process to a specific mount.
Advanced Mounting System (AMS)
AAmsPlayerController
This C++ class forms the base class for Player Controllers in the Demo. It implements the interface and components as necessary in C++. Additionally it implements a method of having the player start moving to a desired location.
AAmsAIController
This C++ class forms the base class for AI Controllers that will also be having their controlled pawns mount and dismount on vehicles and animals. The implementation of the mounting system is identical to that of the AAmsPlayerController
with the minor exception of the movement logic which the AAIController
does not need to move.
BP_AMS_PlayerController
This Blueprint class is a child class of the AAmsPlayerController
. It does not add any additional implementation to the mounting system itself, but does provide do some useful functions such as implementing the Interaction Component, Custom Input swaps, Enabling and Disabling Vehicle HUD, and Setting up useful Multiplayer Debug Logic.
Component and Interfaces
The Controllers need 3 things to be added to them for them to work with the PNM System.
Add RiderControllerComponent
In the Components section of your blueprint add the RiderControllerComponent to it. This component has most of the functionality you will need to implement the following interfaces.
Add IADMUnifiedControllerPawn Interface
In the Interface list in Class Settings add the Unified Controller Pawn Interface. This interface's purpose is to act as a unifying method of retrieving the Core Actor types of Controller, Rider, and Mount between these three actor type. Each of the
Add the IRiderController Interface
In the Inteface list in Class Settings add the IRiderController Interface. This interface's purpose is to give the external world access to key functionalities and information kept within the RiderControllerComponent.
RiderControllerComponent Settings
The RiderControllerComponent has a few settings to keep in mind.
Flag: EnableActionRPCs
Originally the PNM System did not contain any Remote Procedure Calls (RPCs) and you had to set these up on the Controller itself. In later versions of the PNMS, RPCs where added but to remain backwards compatible with older projects a flag was added to enable and disable the original RPCs. Now these built in RPCs are enabled by default. There is no real need to disable them unless you really want to write your own RPCs for all basic actions.
Delegate: OnOwnerPawnChanged
Delegate is called when the Component's Owning Pawn gets changed. The OwnerPawn is the original pawn the player controller was controlling, or your original character. This delegate is called anytime that the original owning pawn is changed for a new one.
Delegate: OnMountActorChanged
This delegate is called whenever the MountActor is changed. It will include both the New Mount as well as the Old Mount. If you are dismounting then the New Mount will always be null.
Delegate: OnLinkedActorChanged
This delegate is very similar to OnMountActorChanged except it deals specifically when a Linked Actor to the mount.
Delegate: OnRiderAdded
This delegate is called anytime a Rider is added to the Mounts Seats.
Delegate: OnRiderRemoved
This delegate is called anytime a rider is removed from the Mount's Seats.
Delegate: OnOtherRiderChangedSeats
This delegate is called when one of the Riders of the Mount changes to a new seat.
Implement the IADMUnifiedControllerPawn Interface
Implementing the functions of the IADMUnifiedControllerPawn interface is fairly straight forward and is similar to the Rider and Mount setup.
PrepareToMount
This function is a preparatory function called by the Controller to make sure that any necessary prerequisites needed for Mounting to Proceed. If this function returns false then the entire mounting process stops. For the controller you can assume to always return true for this function, but there maybe reasons to return false.
Your game may require a player to obtain a key item or unlock the ability to have a mount first. This can be a place to check if the player has achieved the prerequisite in the Controller. This function also exists on the Rider and the Mount as well so each of these three classes can define rules about canceling a mounting operation.
PrepareToDismount
This function is a preparatory function called by the Controller to make sure that any necessary prerequisites needed for Dismounting to Proceed. If this function returns false then the entire dismounting process stops. For the controller you can assume to always return true for this function, but there maybe reasons to return false.
You may have certain mounts that are on a fixed path that move through the world with the player but are not directly controlled by the player. You may need players to stay sitting and enjoy the trip rather than dismount randomly.
IsMounted
This function simply returns if the URiderControllerComponent
is in Mounted Mode.
Implementation
Return the function URiderControllerComponent::IsMounted()
GetCharacterPawn
This function allows you to easily get the Owned Pawn of the controller, this is the players original pawn or character they usually control.
Implementation
Return the function URiderControllerComponent::GetOwnedPawn()
GetCharacterMount
This function allows you to easily get the current mount of the player or AI entity.
Implementation
Return the function URiderControllerComponent::GetMountActor()
GetCharacterController
This function allows you to easily get the controller of the player or AI entity.
Implementation
Return the function URiderControllerComponent::GetOwner()
or Self Blueprint Node
Implement the IRiderController Interface
Implementing the functions of the IRiderController
interface is fairly straight forward as most functions are already implemented in the URiderControllerComponent
GetRiderControllerComponent
This function serves as a catch all to allow you to retrieve the URiderControllerComponent
to directly call functions and get information out of it which may not have an interface function defined to do so.
Returns
- URiderControllerComponent - The Component itself
Implementation
Return the URiderControllerComponent
BeginMountingActor
This interface function is one of two functions that you can call to start the Mounting Operation. This function is an Auto-mount function where the process looks at the current mount and attempts to find the best seat based on your current location to the mount, as apposed to you specifying explicitly which seat the character should mount to.
The mounting process begins here and is broken up into 3 stages total. These three stages exist to allow you to play various animations or move the character into position to get the full effect of the mounting action.
Parameters
- New Mount Actor - the mount you want your rider to attach to
- New Linked Actor - If you are trying to mount to a linked actor, then this parameter will not be null.
Returns
- Mounting Response - This is an
FMountActionResponse
struct that contains information on if the mounting process succeeded or failed. - bool - if this value returns true than the mounting operation is currently proceeding.
Implementation
Return the function URiderControllerComponent::PerformMountActor(newMountActor, NewLinkedActor, MountingResponse)
BeginMountingActorToSeat
This interface function is one of two functions that you can call to start the Mounting Operation. This function is a seat specific mount function where you explicitly specify the seat you wish the character to mount to.
The mounting process begins here and is broken up into 3 stages total. These three stages exist to allow you to play various animations or move the character into position to get the full effect of the mounting action.
Parameters
- New Mount Actor - the mount you want your rider to attach to
- New Linked Actor - If you are trying to mount to a linked actor, then this parameter will not be null.
- Seat Id - this is the integer identifier of the Seat you want to mount to.
Returns
- Mounting Response - This is an
FMountActionResponse
struct that contains information on if the mounting process succeeded or failed. - bool - if this value returns true than the mounting operation is currently proceeding.
Implementation
Return the function URiderControllerComponent::PerformMountActor(newMountActor, NewLinkedActor, MountingResponse)
BeginDismountingActor
This interface function is currently the only function to start the Dismounting Operation. This function is an Auto-dismount function where the process looks at the current mount and Pawn to find the best way to dismount based on how you have implemented some of the later functions on the Mount.
The mounting process begins here and is broken up into 3 stages total. These three stages exist to allow you to play various animations or move the character into position to get the full effect of the mounting action.
Returns
- Mounting Response - This is an
FMountActionResponse
struct that contains information on if the dismounting process succeeded or failed. - bool - if this value returns true than the mounting operation is currently proceeding.
Implementation
Return the function URiderControllerComponent::PerformMountActorToSeat(newMountActor, NewLinkedActor, SeatId, MountingResponse)
BeginChangingSeatToIndex
This function is one of two functions that you can call to start the Seat Changing Process. This function allows you to specify what seat, by index, that you want to move to. If you specify the seat index you are currently attached to then the operation will not occur.
Parameters
- Seat Index - the index of the desired seat to change to
Returns
- Mounting Response - This is an
FMountActionResponse
struct that contains information on if the mounting process succeeded or failed. - bool - if this value returns true than the mounting operation is currently proceeding.
Implementation
Return the function RiderControllerComponent::PerformDismountActor(SeatIndex, MountingResponse)
BeginChangingSeatById
This function is one of two functions that you can call to start the Seat Changing Process. This function allows you to specify what seat by numerical identifier that you want to move to. If you specify the seat id you are currently attached to then the operation will not occur.
Parameters
- Seat Id - The int32 identifier of the seat you want to change to
Returns
- Mounting Response - This is an
FMountActionResponse
struct that contains information on if the mounting process succeeded or failed. - bool - if this value returns true than the seat change operation is currently proceeding.
Implementation
Return the function RiderControllerComponent::PerformChangeSeatById(SeatId, MountingResponse)
PossessPawn
This interface function is leveraged internally by the system to trigger off Mount Possession if the Rider is in the Driver's Seat. The PNM System performs a few house keeping updates when calling this function internally so that the Controller, Mount, and Rider are synced up together.
Params
- PawnToPossess - This is the mount you wish to possess and take control over. This is an input parameter to both the Interface and the component function
Returns
- bool - only exists to keep this a function and not an event, simply return true
Implementation
Call the function URiderControllerComponent::ProssessPawn(PawnToPossess)
OnRiderAdded
This interface function is called by the Mount on all riders to send them messages that a rider has been added to the mount. The URiderControllerComponent::RiderAdded()
function then calls the URiderControllerComponent::OnRiderAdded()
delegate which broadcasts notifications to anything listening to that delegate. This can tie into UI or a messaging system to update players about the make up of their mount.
Params
- New Rider- The Rider that was added to the Mount
- SeatId - the seat id of that the rider was attached to
Returns
-
bool - only exists to keep this a function and not an event, simply return true.
Implementation
Call the function URiderControllerComponent::RiderAdded(NewRider, SeatId)
OnRiderRemoved
This interface function is called by the Mount on all riders to send them messages that a rider has been removed from the mount. The URiderControllerComponent::RiderRemoved()
function then calls the URiderControllerComponent::OnRiderRemoved()
delegate which broadcasts notifications to anything listening to that delegate. This can tie into UI or a messaging system to update players about the make up of their mount.
Params
- RemovedRider - The Rider that was removed from the seat
- SeatId - the seat id of that the rider was removed from
Returns
-
bool - only exists to keep this a function and not an event, simply return true.
Implementation
Call the function URiderControllerComponent::RiderRemoved(RemovedRider, SeatId)
OnOtherRiderChangedSeats
This interface function is called by the Mount on all riders to send them messages that a rider has changed to a new seat. The URiderControllerComponent::OtherRiderChangedSeat()
function then calls the URiderControllerComponent::OnOtherRiderChangedSeat()
delegate which broadcasts notifications to anything listening to that delegate. This can tie into UI or a messaging system to update players about the make up of their mount.
Params
- OtherRider- The Rider that was removed from the seat
- New Seat Id - the seat id of the new seat the rider attached to
- Old Seat Id - the seat id of the original seat the OtherRider was occupying.
Returns
-
bool - only exists to keep this a function and not an event, simply return true.
Implementation
Call the function URiderControllerComponent::OtherRiderChangedSeat(OtherRider, NewSeatId, OldSeatId)
OnPnmsMountingActionFailed
This function was added recently to handle mounting operation failures. Errors that would trigger this should only ever occur because you have messed up the configuration and implementation of the mount for some reason. This allows you to rollback any current settings from the mounting operation.
Params
-
pnmsActionResultArgs - A FPnmsActionEventArgs structure that contains information on why an action failed
Returns
-
bool - only exists to keep this a function and not an event, simply return true.
Implementation
Call the function URiderControllerComponent::ResetToDismounted()
OnPnmsDismountingActionFailed
This function was added recently to handle dismounting operation failures. Errors that would trigger this should only ever occur because you have messed up the configuration and implementation of the mount for some reason. Currently there is no defined implementation but in later versions there will be and is more of an error reporting spot during development
Params
-
pnmsActionResultArgs - A
FPnmsActionEventArgs
structure that contains information on why an action failed
Returns
-
bool - only exists to keep this a function and not an event, simply return true.
Implementation
no current standard implementation for this action.
OnPnmsChangeSeatActionFailed
This function was added recently to handle change seat operation failures. Errors that would trigger this should only ever occur because you have messed up the configuration and implementation of the mount for some reason. This allows you to rollback any current settings from the mounting system. Currently there is no defined implementation but in later versions there will be.
Params
-
pnmsSeatChangeActionResultArgs- A
FPnmsSeatChangeActionEventArgs
structure that contains information on why an action failed
Returns
-
bool - only exists to keep this a function and not an event, simply return true.
Implementation
no current standard implementaiton for this action.
Next Section: Riders