This page covers each function and variable in the included ship pawn BP_BaseShip as well as its Event Graph and how to transfer its logic to your own pawn.
Lets start with how to transfer the Modular Ship Stat System code to your own pawn.
Transfer to your own pawn
It is recommended to transfer movement logic from your other pawn to the included base pawn and make changes on it rather than the other way around as the system uses a lot of Blueprint Interface events and custom events that can be messy to move over to other pawns. However if you wish then follow the below steps.
If you already have a pawn for your project or have a better flight system that fits your needs but still want to use the system for controlling stats and variables on the player pawn you will want to transfer a few things to your own pawn.
The first thing to do on your new pawn is to go to the Class Settings in its blueprint editor and go down to Implemented Interfaces. Click on add and search for BPI_ShipCore and add it. If you want the basic currency system as well on your pawn and don't have your own, add the interface BPI_Shop as well.
Variables to add
Next you need to add a slew of variables to your pawn. They are categorized on the include BP_BaseShip and you can refer to that for reference. If you have your own movement system implemented you don't need all of the Movement variables and if you already have a zoom system for your camera or don't want it you don't have to transfer that logic. The below table shows every variable, its type and it is organized by category. If you have your own movement system on your pawn skip the Movement category.
NOTE: You can simply Ctrl-C and copy the variables from BP_BaseShip and Ctrl-V to paste them on your own pawn, making the process faster.
Also note: the function UpdateMovementVariables is needed even if you are using your own movement system. It updates the movement stats of your pawn regardless. Its current implementation sets the applicable movement variables on the FloatingPawnMovement actor component. If you are using your own movement component you will need to look at this function and change which variables are set by this function to fit your movement component. If you are using a FloatingPawnMovement component just make sure the reference to your component is valid in this function on your new pawn.
Movement Variables
Variable Name | Variable Type | Default Value |
---|---|---|
MovementEnabled | Boolean | True |
VerticalThrusterSpeed | Float | 0.75 |
CanReverse? | Boolean | False |
CanThrottle? | Boolean | False |
Docking
Variable Name | Variable Type | Default Value |
---|---|---|
CanDock? | Boolean | False |
DockingLocation | Vector | 0,0,0 |
DockingStation | Actor - Object Reference | none |
IsDocked? | Boolean | False |
DockingSocket | Name | None |
IsDocking? | Boolean | False |
DockingSpeedLimit | Float | 750.0 |
Shop
Variable Name | Variable Type | Default Value |
---|---|---|
InShop? | Boolean | False |
CurrentStationShopList | Struct - S_StationShopLists | None |
PlayerMoney (can skip this if you have your own currency system) | Float | (Whatever you want the player to start with) |
Ship Config
Variable Name | Variable Type | Default Value |
---|---|---|
BaseShipInfo | Struct - S_BaseShipInformation | (Whatver you want. Covered later in this page) |
Ship Variables
Variable Name | Variable Type | Default Value |
---|---|---|
AttachedActorsAndSockets | Map of Actor(object_ref):Names | none |
MasterShipInfo | Struct - S_MasterShipInfo | (only need to config EngineInfo and EngineShopInfo) |
Functions
Once you have all the variables in your own pawn head over to the functions on BP_BaseShip and copy all the functions there to your new pawn. You can simply right click the function name or select it and Ctrl-C to copy it and paste it on your new pawn.
Once those 5 functions have been copied, repeat the process for the 1 macro on BP_BaseShip called SetUseControlRotation
Event Dispatchers
Last thing to copy over is the 3 Event Dispatchers.
On your new pawn create a new Event Dispatcher. One called OnFinishedDocking, one called OnPlayerMoneyChanged (if using the included currency system), and the last one called OnShipInfoChanged.
Click on OnPlayerMoneyChanged and in the Details on the right click the plus icon to add a parameter. It should be a Float and called NewPlayerMoney.
On the OnShipInfoChanged dispatcher add 2 inputs. One called BaseShipInfo of type Struct - S_BaseShipInformation, and one called MasterShipInfo of type Struct - S_MasterShipInfo.
Nodes
Once all of that is done head over to the Event Graph of BP_BaseShip and select and copy all the nodes on the main graph. If you don't need the movement system or simple zoom only select the graphs on the right of the event graph. Refer to the comments to find the movement graphs to leave behind. Either way, select the graphs needed on the right half at least and copy and paste them onto the event graph of your new pawn.
Once all of that is copied over there will most likely be some errors. If you moved over the movement logic there will be errors related to specific component references. The simple zoom functionality uses references to the Camera and Spring Arm so replace those with the applicable components on your new pawn if necessary. Any references to Capsule in the movement logic is the root component of your pawn so replace those references if needed with a reference to the root component of your new pawn. After that is done the last error will be about a timeline in the collapsed graphs for docking and undocking. Undock Alpha is the output of a Float Track in the timeline node used to time undocking. Sometimes timeline nodes don't copy and paste correctly so if any remaining errors are related to Timeline nodes simply find that timeline node in the BP_BaseShip and manually copy and paste it onto the correct spot in your new pawn and replace the one throwing errors.
Replace References
The last thing to do is in BPI_Shop if you are using the included basic currency system is to change the output variable PlayerReferenceForBinding. So open the interface and select the GetPlayerMoney function and change the PlayerReferenceForBinding variable type from a BP_BaseShip ref to a reference of your new pawn.
Now on your pawn find the interface function GetPlayerMoney and double click it to open its graph. Connect your PlayerMoney variable to the return nodes PlayerMoney and then get a Reference to Self and plug it into the PlayerReferenceForBinding pin on the return node.
Lastly if you want the included base UI that displays basic info for the player to work you need to open WBP_BaseUI and re-bind the events in Event Construct. The two events to re-bind are highlighted in the image below. Simply drag off the PlayerReferenceForBinding pin of the interface function preceding them and search for Bind on Player Money Changed and Bind On Ship Info Changed and replace the existing nodes.
Now you should have a working pawn that will work flawlessly with all the systems in the stat system!