Data Structures
This page will go over some of the key data structures and data elements used by the PNM System.
Enums
Useful Enums to understand their values
EMountingDirection
The PNM System has a built in method of determining the Rider's Relative position to it, however that can also be manipualted by you and your designers to determine how the PNM System determines what is the sides versus the front and back of the mount. The system uses an Enum which gets passed along through the Mounting System to help determine mounting and dismounting directions.
- Invalid Side - No side could be found, this is the default return value
- Any Side - The system respects this to mean that any mounting position available should be used. Often this is the first position of a seat.
- Right Side - The Rider is standing on the Right Side of the Mount
- Left Side - the Rider is standing ont eh Left Side of the Mount
- Front Side - the Rider is standing infront of the mount
- Back Side - the rider is standing in the back of the mount
- Top Side - The Rider is above the mount. This can be used for underwater or space games.
- Bottom Side - the Rider is underneath the mount. This can be used for underwater or space games.
Structs
There are a few important structs that you should be aware of
FMountActionResponse
This struct will be part of the output parameters of nearly all Mounting Operation functions. The mounting, dismounting, and change seat processes have many function that need fire and some of those are asynchronously due to waiting for animations to play or character to finish moving into place. If the mounting process fails at any point you can inspect this structure to understand where and what occurred to cause the system to fail.
For the most part understanding errors will be mainly important during the development of the game. This struct allows you to do additional debugging and allow UI elements to display messages to the player from the mounting system if certain types of "errors" are intentional, such as checking if a player has a key item.
Throughout the mounting process the response is an output parameter that you can also create and inject with your own custom codes you can send through the system.
EMountActionStatusType: ActionStatus
This is an enum that holds a lot of potential reasons for the failure of the mounting process. For the most part each value should be fairly human readable. Additionally it has a "Custom" value that you can set. This allows you to define a second enum with your own error codes for your game.
uint8: CustomStatus
If you are using a custom enum for your mounting process this is where you can set the custom value to any enum you may create.
Flag: Success
If true then the operation succeeded according to the mounting system.
FPnmsActionEventArgs
This struct is part of the new Error Handling system added in the 5.3 version of the plugin. You will find it used in the IRiderControllerInterface. The following functions use it as an parameter
-
OnPnmsMountingActionFailed
-
OnPnmsDismountingActionFailed.
FMountActionResponse: ActionResponse
This is the action response structure that holds any error codes that may have been returned by the PNM System.
Actor: MountActor
Reference to the mount that the event is associated with.
Actor: LinkedMountActor
If the event is related to a seat on a linked actor, then this reference to that linked actor on the mount will be set.
Actor: RiderActor
Reference to the Rider that the event is associated with.
Actor: MountDriver
Reference to the current Driver of the mount, if one exists. Maybe the same as the RiderActor property if the Rider for the event is also the Driver.
int32: SeatId
Identifier of the Seat that the mount event occured for.
FName: SeatName
Name Identifier of the seat that the mount event occured for.
FPnmsChangeSeatActionEventArgs
This struct is part of the new Error Handling system added in the 5.3 version of the plugin. You will find it used in the IRiderControllerInterface. This struct is a child of the FPnmsActionEventArgs struct and has the same properties with a few additions. The following functions use it as an parameter
-
OnPnmsChangeSeatActionFailed
Other Properties
This struct is a child struct of the FPnmsActionEventArgs which means it has the exact same properties of that struct, plus a few additional ones.
int32: DestinationSeatIndex
The index of the seat that the rider is attempting to change to.
FName: DestinationSeatName
The index of the seat that the rider is attempting to change to.
FSeatManager
This struct's main purpose is to define and manage the seats available on a mount. There are several properties that are important to the function of the seat manager.
All UMountablePawnComponents give public access to this manager through its SeatManager property. You can dynamically add, remove, and change seats during runtime or predefine the seats available in Blueprints or C++.
Flag: IsPossessableMount
This is a mount wide setting that indicates that the mount can be possessed and controlled by the player. Set this to false for instances where you do not want the player to ever be able to possess and control the mount.
Flag: ForceDriverSeat
If this flag is set, then the first rider to mount the animal or vehicle will always assume the driver position first. If this is false then the system will mount to the best seat relative to the player.
int32: DriverSeatId
This is the Identifier of the Seat you want to be the Driver Seat. This defaults to an id of 0 as the driver seat. If for some reason you have decided that seat 0 is not your main driver seat then you can change the value here. Additionally the ID of the seat does not have to correspond to its index in the list of Seats maintained by the Seat Manager, but when a new seat is added to the list of seats the UMountablePawnComponent assigns the seat an index based on its current placement or the highest ID value in the list of seats.
int32: DriverSeatIndex
Older versions of the mounting system leveraged the seat index instead of the ID. Now this is automatically updated when the game begins and cannot be directly set. It will eventually be deprecated to reduce confusion.
int32: MaxValidMountingDistanceSquared
This is the squared maximum distance a player needs to be from a given seat position to be able to start the mounting process. This should be similar to your interaciton system's trace distance for determining interactability
For example if you want the player to be able to interact with a mount at 500cm or 500 unreal units, then you need to specify the DistanceSquared as 500 * 500 which is 250,000 units
test
TArray<FSeatData>: Seats
The Seats array is the list of all seats available to this mount. You can add and remove seats in the editor or in C++ through code or some other method of loading seats. More on Seat Data in the next section.
Additionally each FSeatData has a SeatName field that designers can use to easily name specific seats on the mount and that name will display in the Details Panel for easily searching which seats you want to modify or change.
FSeatData
The FSeatData struture is held in an array on the FSeatManager. Each SeatData struct defines exactly one seat on the mount and includes any linked actor seats that are considered part of the mount.
FName: SeatName
This is a Developer Friendly name that can be given to a specified seat. The seat name is then displayed as part of the Array in the FSeatManager for easily identifying which seat you wish to edit on the mount.
int32: SeatId
This is a numeric seat identifier that is given to all Seats automatically by the UMountablePawnComponent when a seat is created. You can override the seat identifier manually and the UMountablePawnComponent will adjust accordingly.
FName: SeatSocketName
This FName needs to correspond to either a Bone or a Socket Created on the Mounts Skeletal Mesh. This is what the Mounting system leverages to attach the player to the mounts body.
Flag: IsOccupied
This flag is set by the PNM System when a rider is assigned to this seat through Mounting. This should not be manually changed. In the editor you can see this value during testing to validate mounting.
Flag: IsLinkedActor
This flag indicates that this seat belongs to a linked actor
AActor: OccupyingActor
This property is a reference to the Rider who is occupying this seat.
TArray<FSeatMountingData>: MountingData
This array lists the series of ways a Rider may mount to this specific seat. For many Vehicles a Seat may only have one entry and exit point. However for some mounts like a horse you may be able to mount the animal from the Right and the Left side or even the Front and the Back.
FSeatMountingData
You can think of this structure as the Mounting Point for the Seat, where the player must be relative to the seat to begin mounting.
int32: SeatMountId
This is an automatically assigned value for the SeatMountingData. While it is visible in the editor it is not editable. This is a precursor to future development allowing you to continuously query for the mounting point even while it is moving.
EMountingDirection: MountPosition
This is the relative position from the mount that a Rider needs to be for this to be a valid mountable seat.
FVector: RelativeMountingOffset
This is an FVector used to designate about where the Mounting Point is located Relative to the Pivot point of the Mount's Root Scene Component. For instance if the Mount is a Character Based Mount then the Root Scene Component would be the Capsule Component. You can use the Editor to adjust the Mounting Points using the Transformation Gismos in the Blueprint Viewport or even on a per-instance basis for mounts placed down in the world.
FVector: RelativeDismountingOffset
This is an FVector used to designate about where the corresponding Dismounting Point is located Relative to the Pivot point of the Mount's Root Scene Component. For instance if the Mount is a Character Based Mount then the Root Scene Component would be the Capsule Component. You can use the Editor to adjust the Dismounting Points using the Transformation Gismos in the Blueprint Viewport or even on a per-instance basis for mounts placed down in the world. There maybe reasons you want the Dismounting location and the Mounting location to be different due to collision or other reasons.
Flag: UseCustomDismountingOffset
If this is set to true, then the This Mount Point will use the RelativeDismountingOffset for dismounting. If this is set to false then the Mount Point will use the RelativeMountingOffset for dismounting instead.
Utility Functions
Utility functions are part of the UAdsMountingSystemLibrary which is a UE Function Library.
GetAngleFromForwardBetweenActors
This funciton takes two actors and uses their positions with their forward facing direcitons to determine how much in front the target actor is from the main actor. This funciton returns a value between -1 and 1 which will tell you by what degree the target actor is in front or behind the main actor.
- Value will be 1.0 or nearly 1.0 if the target actor is directly in front of the main actor
- Value will be -1 or nearly -1 if the target actor is directly behind the main actor.
- if the value 0 or nearly 0 then the target actor is on the right or the left of the main actor, but there is no way to tell on which side using this function.
- All values between 0 and 1 place the target actor near the front half of the target with 0.45f being on the left or right intercardinal front of the mount.
- All values between -1 and 0 place the target actor near the back half of the main actor with 0.45 being on the left or right intercardinal rear of the mount.
You can combine this function with GetAngleRightBetweenActors() to determine how much to the right or left an actor is and GetAngleUpBetweenActors() to determine how much above or below an actor is to the mount.
Parameters
- Main Actor - the main actor you want to get the relative direction for
- Target Actor - the actor you want to get the relative direction for the main actor against.
Returns
-
float - returns a value between -1 and 1
GetAngleFromRightBetweenActors
This function takes two actors and uses their positions with their forward facing directions to determine how much to the right the target actor is from the main actor. This function returns a value between -1 and 1 which will tell you by what degree the target actor is to the right or left of the main actor.
- Value will be 1.0 or nearly 1.0 if the target actor is directly to the right of the main actor
- Value will be -1 or nearly -1 if the target actor is directly to the left of the main actor.
- if the value 0 or nearly 0 then the target actor is in front or behind the main actor, but there is no way to tell on which side using this function.
- All values between 0 and 1 place the target actor near the right half of the target with 0.45f being on the forward or rear intercardinal right side of the mount.
- All values between -1 and 0 place the target actor near the left half of the main actor with 0.45 being on the forward or rear intercardinal left side of the mount.
You can combine this function with GetAngleForwardBetweenActors() to determine how much to the right or left an actor is and GetAngleUpBetweenActors() to determine how much above or below an actor is to the mount.
Parameters
- Main Actor - the main actor you want to get the relative direction for
- Target Actor - the actor you want to get the relative direction for the main actor against.
Returns
-
float - returns a value between -1 and 1
GetAngleFromUpBetweenActors
This function takes two actors and uses their positions with their forward facing directions to determine how much above the target actor is from the main actor. This function returns a value between -1 and 1 which will tell you by what degree the target actor is above or below of the main actor.
- Value will be 1.0 or nearly 1.0 if the target actor is directly above the main actor
- Value will be -1 or nearly -1 if the target actor is directly below the main actor.
- if the value 0 or nearly 0 then the target actor is either directly infront, behind, to the right, or to the left of the main actor, but there is no way to tell on which side using this function.
- All values between 0 and 1 place the target actor in the upper region of the target with 0.45f being on the being any of the standard cardinal and intercardinal directions of the mount.
- All values between -1 and 0 place the target actor near the lower half of the main actor with 0.45 being any of the standard cardnal and intercardinal directions of the mount.
You can combine this function with GetAngleForwardBetweenActors() to determine how much to the right or left an actor is and GetAngleRightBetweenActors() to determine how much above or below an actor is to the mount.
Parameters
- Main Actor - the main actor you want to get the relative direction for
- Target Actor - the actor you want to get the relative direction for the main actor against.
Returns
-
float - returns a value between -1 and 1