Building Build Component¶
UBuildingBuildComponent is the primary entry point for local building interactions. It is responsible for:
- Build Mode
- Building previews
- Building selection and editing
- Rotation and position adjustments
- Socket snapping
- Cost evaluation for UI
- Default building UI
This component is typically added to a player-controlled Pawn or Character.
Note
Building creation, movement, and removal should be initiated through UBuildingBuildComponent.
Final placement validation and Entity modifications are performed by the server.
Basic Information¶
| Item | Description |
|---|---|
| Class | UBuildingBuildComponent |
| Base Class | UActorComponent |
| Recommended Owner | Player-controlled Pawn or Character |
| Primary Purpose | Local building interaction and preview control |
| Blueprint Support | Supported |
| Server Validation | Handled by the building world system |
| Default UI | Can be created and managed automatically by the plugin |
Basic Workflow¶
Build States¶
EBuildState represents the component's current build state.
| State | Description |
|---|---|
Idle |
Build Mode is disabled. |
Ready |
Build Mode is active, but no operation is currently in progress. |
Build |
A new building is being placed. |
Edit |
An existing building is being edited. |
Common state transitions:
Idle → Ready
Enter Build Mode
Ready → Build
Start placing a new building
Ready → Edit
Start editing an existing building
Build / Edit → Ready
Complete or cancel the current operation
Any active state → Idle
Exit Build Mode
Build Mode APIs¶
| API | Description |
|---|---|
ToggleBuildMode |
Toggles Build Mode. |
EnterBuild |
Enters Build Mode. |
ExitBuild |
Completely exits Build Mode. |
CancelBuild |
Cancels the current operation and returns to Ready. |
GetCurrentBuildState |
Returns the current build state. |
IsInBuildMode |
Checks whether Build Mode is active. |
HasActiveBuildOperation |
Checks whether a building is currently being placed or edited. |
ToggleBuildMode¶
Toggles Build Mode.
If the current state is Idle, the component enters Build Mode. Otherwise, it exits Build Mode.
EnterBuild¶
Enters Build Mode without immediately placing a building.
After this function is called, the state changes to Ready.
ExitBuild¶
Completely exits Build Mode.
This function clears the current preview, selection, and editing state, then changes the state to Idle.
CancelBuild¶
Cancels the current placement or editing operation.
The component remains in Build Mode, and the state returns to Ready.
GetCurrentBuildState¶
Returns the current build state.
| Type | Data Type | Description |
|---|---|---|
| Return | EBuildState |
The current build state. |
IsInBuildMode¶
Checks whether Build Mode is active.
| Type | Data Type | Description |
|---|---|---|
| Return | bool |
Returns true when the current state is not Idle. |
HasActiveBuildOperation¶
Checks whether an active building operation exists.
| Type | Data Type | Description |
|---|---|---|
| Return | bool |
Returns true when the current state is Build or Edit. |
Building Operation APIs¶
| API | Description |
|---|---|
StartBuild |
Starts placing a new building. |
RotateBuild |
Rotates the current building preview. |
AdjustBuildHeight |
Adjusts the building preview height. |
AdjustBuildDistance |
Adjusts the building preview distance. |
ConfirmBuild |
Confirms the current operation. |
DeleteBuild |
Removes the building currently being edited. |
StartEditBuild |
Starts editing the currently highlighted building. |
GetCurrentOperationEntityId |
Returns the Entity ID currently being edited. |
GetCurrentBuildingData |
Returns the building data used by the current operation. |
StartBuild¶
Starts placing the specified building.
UFUNCTION(BlueprintCallable, Category = "Building|Operation")
void StartBuild(
UBuildingDataAsset* Data
);
| Type | Name | Data Type | Description |
|---|---|---|---|
| Param | Data |
UBuildingDataAsset* |
The building data asset to place. |
After this function is called, the component creates a building preview and enters the Build state.
RotateBuild¶
Rotates the current building preview.
| Type | Name | Data Type | Description |
|---|---|---|---|
| Param | YawDelta |
float |
The Yaw angle added by this operation. |
For example, to rotate by 90 degrees each time:
AdjustBuildHeight¶
Adjusts the height offset of the current building preview.
UFUNCTION(BlueprintCallable, Category = "Building|Operation")
void AdjustBuildHeight(
float HeightDelta
);
| Type | Name | Data Type | Description |
|---|---|---|---|
| Param | HeightDelta |
float |
The amount of height added or removed by this operation. |
A positive value moves the preview upward, while a negative value moves it downward.
AdjustBuildDistance¶
Adjusts the distance between the building preview and the component's Owner.
UFUNCTION(BlueprintCallable, Category = "Building|Operation")
void AdjustBuildDistance(
float InputValue
);
| Type | Name | Data Type | Description |
|---|---|---|---|
| Param | InputValue |
float |
The adjustment direction, typically -1 or 1. |
The actual distance adjustment is:
| Input Value | Result |
|---|---|
1 |
Moves the preview farther away. |
-1 |
Moves the preview closer. |
Build Distance Step is configured in the plugin settings.
ConfirmBuild¶
Confirms the current operation.
The behavior depends on the current state:
| Current State | Behavior |
|---|---|
Build |
Submits a request to place a new building. |
Edit |
Submits the updated building position. |
Ready |
Processes the current building selection. |
Final position validation, cost consumption, and Entity modifications are performed by the server.
DeleteBuild¶
Removes the building currently being edited.
This function only takes effect when a valid Edit operation exists.
StartEditBuild¶
Starts editing the currently highlighted building.
If successful, the component enters the Edit state and creates an editing preview.
GetCurrentOperationEntityId¶
Returns the Entity ID of the building currently being edited.
UFUNCTION(BlueprintPure, Category = "Building|Operation")
int32 GetCurrentOperationEntityId() const;
| Type | Data Type | Description |
|---|---|---|
| Return | int32 |
The current Entity ID, or INDEX_NONE when no valid target exists. |
GetCurrentBuildingData¶
Returns the building data used by the current operation.
UFUNCTION(BlueprintPure, Category = "Building|Operation")
UBuildingDataAsset* GetCurrentBuildingData() const;
| Type | Data Type | Description |
|---|---|---|
| Return | UBuildingDataAsset* |
The current building data, or possibly nullptr when no operation is active. |
Building Evaluation APIs¶
EvaluateBuildForUI¶
Evaluates building costs and construction requirements for UI display.
UFUNCTION(BlueprintCallable, Category = "Building|Evaluation")
FBuildingBuildCheckResult EvaluateBuildForUI(
const UBuildingDataAsset* BuildingData,
const FTransform& PreviewTransform
) const;
| Type | Name | Data Type | Description |
|---|---|---|---|
| Param | BuildingData |
const UBuildingDataAsset* |
The building data to evaluate. |
| Param | PreviewTransform |
const FTransform& |
The world transform of the building preview. |
| Return | CheckResult |
FBuildingBuildCheckResult |
Cost and failure information. |
This function is used only for UI evaluation and does not consume resources.
Owner APIs¶
GetOwningController¶
Returns the Controller associated with the Pawn that owns this component.
| Type | Data Type | Description |
|---|---|---|
| Return | AController* |
The Owner Pawn's Controller, or nullptr if unavailable. |
Aiming APIs¶
EBuildingAimMode determines the origin of the building trace.
| Mode | Description |
|---|---|
CameraCenter |
Traces from the camera or the center of the screen. |
MouseCursor |
Traces from the mouse cursor position. |
SetBuildingAimMode¶
Changes the current aiming mode.
UFUNCTION(BlueprintCallable, Category = "Building|Aim")
void SetBuildingAimMode(
EBuildingAimMode NewAimMode
);
| Type | Name | Data Type | Description |
|---|---|---|---|
| Param | NewAimMode |
EBuildingAimMode |
The new aiming mode. |
GetBuildingAimMode¶
Returns the current aiming mode.
| Type | Data Type | Description |
|---|---|---|
| Return | EBuildingAimMode |
The current aiming mode. |
The default value is loaded from the plugin settings when the component is initialized.
Snap Candidate APIs¶
| API | Description |
|---|---|
SelectNextSnapPoint |
Selects the next snap candidate. |
SelectPreviousSnapPoint |
Selects the previous snap candidate. |
GetSnapCandidateCount |
Returns the current number of candidates. |
GetActiveSnapCandidateIndex |
Returns the current candidate index. |
ToggleSnapActive |
Enables or disables Socket snapping. |
GetSnapActiveState |
Returns whether snapping is currently enabled. |
SelectNextSnapPoint¶
Selects the next compatible snap candidate.
| Type | Data Type | Description |
|---|---|---|
| Return | bool |
Returns true when a candidate is selected successfully. |
This function prioritizes the current cache and does not actively perform a new area search.
SelectPreviousSnapPoint¶
Selects the previous compatible snap candidate.
| Type | Data Type | Description |
|---|---|---|
| Return | bool |
Returns true when a candidate is selected successfully. |
GetSnapCandidateCount¶
Returns the number of currently cached snap candidates.
| Type | Data Type | Description |
|---|---|---|
| Return | int32 |
The current number of candidates. |
GetActiveSnapCandidateIndex¶
Returns the index of the currently selected candidate.
| Type | Data Type | Description |
|---|---|---|
| Return | int32 |
The current index, or INDEX_NONE when not snapped. |
ToggleSnapActive¶
Enables or disables Socket snapping for the current component.
When disabled, the building preview does not automatically apply Socket snapping.
Call this function again to re-enable snapping.
GetSnapActiveState¶
Returns whether snapping is currently enabled.
| Type | Data Type | Description |
|---|---|---|
| Return | bool |
Returns true when snapping is enabled. |
For snapping configuration, see Snapping System.
Events¶
| Event | Description |
|---|---|
OnBuildingCheck |
Triggered when the Ghost performs a placement validation check. |
OnBuildingSelected |
Triggered when the selected building data changes. |
OnBuildStateChanged |
Triggered when the build state changes. |
OnBuildingCheck¶
Triggered when the building preview performs a placement validation check.
Delegate declaration:
| Type | Name | Data Type | Description |
|---|---|---|---|
| Param | Context |
FGhostCheckResultContext |
The current Ghost validation result. |
This event can be used to update:
- Placement availability indicators
- Failure reasons
- Building preview UI
- Custom validation messages
OnBuildingSelected¶
Triggered when the currently selected building data changes.
UPROPERTY(BlueprintAssignable, Category = "Building|Events")
FOnBuildingSelected OnBuildingSelected;
Delegate declaration:
| Type | Name | Data Type | Description |
|---|---|---|---|
| Param | Data |
UBuildingDataAsset* |
The currently selected building data. |
This event can be used to update building details, cost information, or selection UI.
OnBuildStateChanged¶
Triggered when the build state changes.
UPROPERTY(BlueprintAssignable, Category = "Building|Events")
FOnBuildStateChanged OnBuildStateChanged;
Delegate declaration:
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(
FOnBuildStateChanged,
EBuildState,
PreviousState,
EBuildState,
NewState
);
| Type | Name | Data Type | Description |
|---|---|---|---|
| Param | PreviousState |
EBuildState |
The state before the change. |
| Param | NewState |
EBuildState |
The state after the change. |
This event can be used to:
- Show or hide the building UI
- Switch input mappings
- Update operation prompts
- Determine whether an operation was completed or canceled
Default UI¶
When UI Handling Mode in the project settings is set to Use Default, the component automatically manages the default building interface.
| State | Default UI Behavior |
|---|---|
Idle |
Hides the building interface. |
Ready |
Displays the building selection interface. |
Build |
Displays building placement information. |
Edit |
Displays building editing information. |
Projects generally only need to call:
When using a custom UI, listen to:
For UI configuration, see Plugin Settings.
Multiplayer¶
| Operation | Execution Location |
|---|---|
| Input handling | Local player |
| Ghost Preview | Local player |
| Snap candidate calculation | Local player |
| Cost evaluation for UI | Local player |
| Building request submission | Local player |
| Final position validation | Server |
| Resource consumption | Server |
| Entity creation, movement, and removal | Server |
| Building result synchronization | Plugin networking system |
UBuildingBuildComponent handles local interactions but does not bypass server-authoritative validation.
Recommended Input Mappings¶
| Input | Recommended API |
|---|---|
| Toggle Build Mode | ToggleBuildMode |
| Confirm | ConfirmBuild |
| Cancel | CancelBuild |
| Rotate | RotateBuild |
| Adjust height | AdjustBuildHeight |
| Adjust distance | AdjustBuildDistance |
| Next snap point | SelectNextSnapPoint |
| Previous snap point | SelectPreviousSnapPoint |
| Enable or disable snapping | ToggleSnapActive |
| Remove building | DeleteBuild |
| Start editing | StartEditBuild |
Troubleshooting¶
| Issue | What to Check |
|---|---|
| Unable to enter Build Mode | Check whether the component is attached to the local player's Pawn. |
StartBuild does not create a preview |
Check the Building Data Asset and Preview Mesh. |
ConfirmBuild does not create a building |
Check Ghost validity, building costs, and the server request. |
| Unable to select a building | Check the building selection collision channel. |
| Unable to enter the editing state | Check whether a valid building is highlighted. |
| Rotation has no effect | Check whether an active building preview exists. |
| Unable to find snap points | Check the snapping state, collision channels, and Snap configuration. |
| Unable to switch snap points | Check whether multiple compatible candidates exist. |
| Default UI is not displayed | Check UI Handling Mode and Build Widget Class. |
| Custom UI does not update | Check whether the relevant events are bound correctly. |
| Client operations do not respond | Check the Request Actor and server connection. |