### Implement a Runtime Editor Pawn in C++ Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt This example defines a custom pawn class inheriting from ATransformerPawn, implementing selection logic, input bindings, and transformation settings. ```cpp // MyRuntimeEditorPawn.h #pragma once #include "CoreMinimal.h" #include "TransformerPawn.h" #include "MyRuntimeEditorPawn.generated.h" UCLASS() class MYGAME_API AMyRuntimeEditorPawn : public ATransformerPawn { GENERATED_BODY() public: AMyRuntimeEditorPawn(); virtual void BeginPlay() override; virtual void Tick(float DeltaTime) override; virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override; // Override selection filter virtual bool ShouldSelect_Implementation(AActor* OwnerActor, USceneComponent* Component) override; // Override selection change event virtual void OnComponentSelectionChange_Implementation(USceneComponent* Component, bool bSelected, bool bImplementsUFocusable) override; protected: void OnLeftMousePressed(); void OnLeftMouseReleased(); void OnRightMousePressed(); void SwitchToTranslation(); void SwitchToRotation(); void SwitchToScale(); void ToggleSpace(); void ToggleSnapping(); void DuplicateSelection(); void DeleteSelection(); private: UPROPERTY(EditDefaultsOnly, Category = "Editor") float TraceDistance = 50000.0f; UPROPERTY(EditDefaultsOnly, Category = "Editor") TArray> SelectionChannels; bool bIsLeftMouseDown = false; }; // MyRuntimeEditorPawn.cpp #include "MyRuntimeEditorPawn.h" #include "Kismet/GameplayStatics.h" AMyRuntimeEditorPawn::AMyRuntimeEditorPawn() { PrimaryActorTick.bCanEverTick = true; // Setup default selection channels SelectionChannels.Add(ECollisionChannel::ECC_WorldStatic); SelectionChannels.Add(ECollisionChannel::ECC_WorldDynamic); SelectionChannels.Add(ECollisionChannel::ECC_PhysicsBody); } void AMyRuntimeEditorPawn::BeginPlay() { Super::BeginPlay(); // Initialize with translation gizmo in world space SetTransformationType(ETransformationType::TT_Translation); SetSpaceType(ESpaceType::ST_World); SetComponentBased(false); // Select entire actors // Setup snapping defaults SetSnappingValue(ETransformationType::TT_Translation, 50.0f); SetSnappingValue(ETransformationType::TT_Rotation, 15.0f); SetSnappingValue(ETransformationType::TT_Scale, 0.25f); } void AMyRuntimeEditorPawn::Tick(float DeltaTime) { Super::Tick(DeltaTime); // Continuous selection/transform update while mouse is held if (bIsLeftMouseDown) { TArray IgnoredActors; IgnoredActors.Add(this); MouseTraceByObjectTypes(TraceDistance, SelectionChannels, IgnoredActors, false); } } void AMyRuntimeEditorPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); // Mouse input PlayerInputComponent->BindAction("LeftMouse", IE_Pressed, this, &AMyRuntimeEditorPawn::OnLeftMousePressed); PlayerInputComponent->BindAction("LeftMouse", IE_Released, this, &AMyRuntimeEditorPawn::OnLeftMouseReleased); PlayerInputComponent->BindAction("RightMouse", IE_Pressed, this, &AMyRuntimeEditorPawn::OnRightMousePressed); // Transform mode shortcuts PlayerInputComponent->BindAction("TranslateMode", IE_Pressed, this, &AMyRuntimeEditorPawn::SwitchToTranslation); PlayerInputComponent->BindAction("RotateMode", IE_Pressed, this, &AMyRuntimeEditorPawn::SwitchToRotation); PlayerInputComponent->BindAction("ScaleMode", IE_Pressed, this, &AMyRuntimeEditorPawn::SwitchToScale); // Utility shortcuts PlayerInputComponent->BindAction("ToggleSpace", IE_Pressed, this, &AMyRuntimeEditorPawn::ToggleSpace); PlayerInputComponent->BindAction("ToggleSnap", IE_Pressed, this, &AMyRuntimeEditorPawn::ToggleSnapping); PlayerInputComponent->BindAction("Duplicate", IE_Pressed, this, &AMyRuntimeEditorPawn::DuplicateSelection); PlayerInputComponent->BindAction("Delete", IE_Pressed, this, &AMyRuntimeEditorPawn::DeleteSelection); } bool AMyRuntimeEditorPawn::ShouldSelect_Implementation(AActor* OwnerActor, USceneComponent* Component) { if (!OwnerActor) return false; // Don't allow selecting the editor pawn itself if (OwnerActor == this) return false; // Only allow actors tagged as "Editable" if (OwnerActor->Tags.Contains(FName("Editable"))) { return true; } return false; } void AMyRuntimeEditorPawn::OnComponentSelectionChange_Implementation( USceneComponent* Component, bool bSelected, bool bImplementsUFocusable) { // Apply highlight effect to objects that don't implement IFocusableObject if (!bImplementsUFocusable && Component) { if (UPrimitiveComponent* Primitive = Cast(Component)) { Primitive->SetRenderCustomDepth(bSelected); Primitive->SetCustomDepthStencilValue(bSelected ? 1 : 0); } } } ``` -------------------------------- ### SelectActor C++ Function Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Directly selects an actor by adding its root component to the selection list. Use 'bAppendToList' to add to the current selection or start a new one. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") void SelectActor(AActor* Actor, bool bAppendToList = false); ``` ```cpp // Example: Programmatically select actors void AMyEditorPawn::SelectSpecificActors() { // Find actors by tag and select them TArray FoundActors; UGameplayStatics::GetAllActorsWithTag(GetWorld(), FName("Selectable"), FoundActors); if (FoundActors.Num() > 0) { // Select first actor (clears previous selection) SelectActor(FoundActors[0], false); // Append remaining actors to selection for (int32 i = 1; i < FoundActors.Num(); i++) { SelectActor(FoundActors[i], true); } } } ``` -------------------------------- ### ServerApplyTransform Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Server RPC to apply transformation that will be multicast to all clients. ```APIDOC ## ServerApplyTransform ### Description Server RPC to apply transformation that will be multicast to all clients. ### Parameters #### Request Body - **DeltaTransform** (FTransform) - Required - The transformation delta to apply. ``` -------------------------------- ### Define EGizmoPlacement Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Defines the placement logic for the gizmo when multiple objects are selected. ```cpp UENUM(BlueprintType) enum class EGizmoPlacement : uint8 { GP_None UMETA(DisplayName = "None"), GP_OnFirstSelection UMETA(DisplayName = "On First Selection"), GP_OnLastSelection UMETA(DisplayName = "On Last Selection"), }; ``` -------------------------------- ### Toggle Editor Settings Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Methods to toggle between coordinate spaces and enable or disable snapping for all transformation types. ```cpp void AMyRuntimeEditorPawn::ToggleSpace() { static bool bIsWorldSpace = true; bIsWorldSpace = !bIsWorldSpace; SetSpaceType(bIsWorldSpace ? ESpaceType::ST_World : ESpaceType::ST_Local); GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Yellow, bIsWorldSpace ? TEXT("World Space") : TEXT("Local Space")); } void AMyRuntimeEditorPawn::ToggleSnapping() { static bool bSnappingEnabled = false; bSnappingEnabled = !bSnappingEnabled; SetSnappingEnabled(ETransformationType::TT_Translation, bSnappingEnabled); SetSnappingEnabled(ETransformationType::TT_Rotation, bSnappingEnabled); SetSnappingEnabled(ETransformationType::TT_Scale, bSnappingEnabled); GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Cyan, bSnappingEnabled ? TEXT("Snapping ON") : TEXT("Snapping OFF")); } ``` -------------------------------- ### Register Gizmo Domain Components Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Associate custom scene components with specific transformation domains for gizmo interaction. ```cpp UFUNCTION(BlueprintCallable, Category = "Gizmo") void RegisterDomainComponent( class USceneComponent* Component, ETransformationDomain Domain ); // Example: Create custom gizmo with additional handles void AMyCustomGizmo::SetupCustomHandles() { // Create additional handles UBoxComponent* CustomHandle = CreateDefaultSubobject(TEXT("CustomHandle")); CustomHandle->SetupAttachment(ScalingScene); CustomHandle->SetBoxExtent(FVector(20.0f)); // Register it to work with XYZ uniform transformation RegisterDomainComponent(CustomHandle, ETransformationDomain::TD_XYZ); } ``` -------------------------------- ### Configure Component or Actor Selection Mode Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Toggles between selecting individual components or entire actors. Use `SetComponentBased(false)` for actor selection and `SetComponentBased(true)` for component selection. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") void SetComponentBased(bool bIsComponentBased); ``` ```cpp // Example: Toggle between actor and component selection modes void AMyEditorPawn::SetActorSelectionMode() { SetComponentBased(false); UE_LOG(LogTemp, Log, TEXT("Now selecting entire actors")); } void AMyEditorPawn::SetComponentSelectionMode() { SetComponentBased(true); UE_LOG(LogTemp, Log, TEXT("Now selecting individual components")); } ``` -------------------------------- ### ABaseGizmo API Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Methods for managing gizmo domains, registration, and visual scaling. ```APIDOC ## GetTransformationDomain ### Description Determines which transformation domain a hit component belongs to. ### Parameters - **ComponentHit** (USceneComponent*) - Required - The component that was hit. ## RegisterDomainComponent ### Description Registers a component to be associated with a specific transformation domain. ### Parameters - **Component** (USceneComponent*) - Required - The component to register. - **Domain** (ETransformationDomain) - Required - The domain to associate with the component. ## SetTransformProgressState ### Description Sets whether a transformation is currently in progress. ### Parameters - **bInProgress** (bool) - Required - Current state of the transformation. - **CurrentDomain** (ETransformationDomain) - Required - The active transformation domain. ## ScaleGizmoScene ### Description Scales the gizmo to maintain consistent screen size regardless of camera distance. ### Parameters - **ReferenceLocation** (FVector) - Required - The camera location. - **ReferenceLookDirection** (FVector) - Required - The camera look direction. - **FieldOfView** (float) - Optional - The camera FOV (default 90.f). ``` -------------------------------- ### GetSelectedComponents API and Usage Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Retrieves the list of selected components and the component currently holding the gizmo. Use this to synchronize UI elements with the current selection state. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") void GetSelectedComponents( TArray& outComponentList, class USceneComponent*& outGizmoPlacedComponent ) const; // Example: Display selection info in UI void AMyEditorPawn::UpdateSelectionUI() { TArray SelectedComponents; USceneComponent* GizmoComponent; GetSelectedComponents(SelectedComponents, GizmoComponent); FString SelectionText = FString::Printf(TEXT("Selected: %d objects"), SelectedComponents.Num()); if (GizmoComponent) { SelectionText += FString::Printf(TEXT("\nGizmo on: %s"), *GizmoComponent->GetOwner()->GetName()); } // Update UI widget with SelectionText SelectionInfoWidget->SetText(FText::FromString(SelectionText)); } ``` -------------------------------- ### Define and Use ETransformationDomain Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Represents the active axis or plane for gizmo interaction and demonstrates how to query the current state. ```cpp UENUM(BlueprintType) enum class ETransformationDomain : uint8 { TD_None UMETA(DisplayName = "None"), TD_X_Axis UMETA(DisplayName = "X Axis"), TD_Y_Axis UMETA(DisplayName = "Y Axis"), TD_Z_Axis UMETA(DisplayName = "Z Axis"), TD_XY_Plane UMETA(DisplayName = "XY Plane"), TD_YZ_Plane UMETA(DisplayName = "YZ Plane"), TD_XZ_Plane UMETA(DisplayName = "XZ Plane"), TD_XYZ UMETA(DisplayName = "XYZ"), }; // Example: Check current transformation domain void AMyGamePawn::CheckTransformationState() { bool bTransformInProgress; ETransformationDomain CurrentDomain = TransformerPawn->GetCurrentDomain(bTransformInProgress); if (bTransformInProgress) { switch (CurrentDomain) { case ETransformationDomain::TD_X_Axis: UE_LOG(LogTemp, Log, TEXT("Transforming on X Axis")); break; case ETransformationDomain::TD_XY_Plane: UE_LOG(LogTemp, Log, TEXT("Transforming on XY Plane")); break; // ... handle other domains } } } ``` -------------------------------- ### Mouse Trace by Object Types Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Performs a mouse-based line trace to select objects or interact with the gizmo using collision object types. Specify desired collision channels and actors to ignore. The `bAppendToList` parameter controls whether results are added to or replace the current selection. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") bool MouseTraceByObjectTypes( float TraceDistance, TArray> CollisionChannels, TArray IgnoredActors, bool bAppendToList = false ); ``` ```cpp // Example: Select objects on left mouse click void AMyEditorPawn::OnLeftMouseClick() { TArray> Channels; Channels.Add(ECollisionChannel::ECC_WorldStatic); Channels.Add(ECollisionChannel::ECC_WorldDynamic); Channels.Add(ECollisionChannel::ECC_PhysicsBody); TArray IgnoredActors; IgnoredActors.Add(this); // Ignore self // Single selection (replace previous selection) bool bHitSomething = MouseTraceByObjectTypes(10000.0f, Channels, IgnoredActors, false); if (bHitSomething) { UE_LOG(LogTemp, Log, TEXT("Object selected or gizmo activated")); } } ``` ```cpp // Example: Multi-selection with Shift held void AMyEditorPawn::OnLeftMouseClickWithShift() { TArray> Channels; Channels.Add(ECollisionChannel::ECC_WorldStatic); Channels.Add(ECollisionChannel::ECC_WorldDynamic); TArray IgnoredActors; // Append to existing selection MouseTraceByObjectTypes(10000.0f, Channels, IgnoredActors, true); } ``` -------------------------------- ### Handle Gizmo Transformation State Changes Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Blueprint-overridable event triggered when the gizmo's transformation state changes (start/end). Use this to play sounds or trigger other actions during transformations. ```cpp UFUNCTION(BlueprintNativeEvent, Category = "Runtime Transformer") void OnGizmoStateChanged( ETransformationType GizmoType, bool bTransformInProgress, ETransformationDomain Domain ); ``` ```cpp // Example: Play sound effects on transformation void AMyEditorPawn::OnGizmoStateChanged_Implementation( ETransformationType GizmoType, bool bTransformInProgress, ETransformationDomain Domain) { if (bTransformInProgress) { // Started transforming UGameplayStatics::PlaySound2D(this, TransformStartSound); } else { // Finished transforming UGameplayStatics::PlaySound2D(this, TransformEndSound); } } ``` -------------------------------- ### ShouldSelect Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Blueprint-overridable function to filter which objects can be selected. ```APIDOC ## ShouldSelect ### Description Blueprint-overridable function to filter which objects can be selected. ### Parameters - **OwnerActor** (AActor*) - Required - The actor to evaluate. - **Component** (USceneComponent*) - Required - The component to evaluate. ### Response - **Return** (bool) - Returns true if the object is selectable. ``` -------------------------------- ### Handle Mouse Input Events Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Methods for processing mouse button presses and releases to trigger selection logic or clear domains. ```cpp void AMyRuntimeEditorPawn::OnLeftMousePressed() { bIsLeftMouseDown = true; TArray IgnoredActors; IgnoredActors.Add(this); // Check if Shift is held for multi-select APlayerController* PC = Cast(GetController()); bool bAppend = PC && PC->IsInputKeyDown(EKeys::LeftShift); MouseTraceByObjectTypes(TraceDistance, SelectionChannels, IgnoredActors, bAppend); } void AMyRuntimeEditorPawn::OnLeftMouseReleased() { bIsLeftMouseDown = false; ClearDomain(); } void AMyRuntimeEditorPawn::OnRightMousePressed() { DeselectAll(false); } ``` -------------------------------- ### Mouse Trace by Profile Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Performs a mouse-based line trace using a named collision profile for selection. This allows for more complex collision filtering defined in project settings. The `bAppendToList` flag indicates whether to add to or replace the current selection. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") bool MouseTraceByProfile( float TraceDistance, const FName& ProfileName, TArray IgnoredActors, bool bAppendToList = false ); ``` ```cpp // Example: Using custom collision profile for selection void AMyEditorPawn::SelectWithCustomProfile() { TArray IgnoredActors; // Use a custom collision profile defined in Project Settings MouseTraceByProfile( 10000.0f, FName("SelectableObjects"), IgnoredActors, false ); } ``` -------------------------------- ### OnGizmoStateChanged Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Blueprint-overridable event called when the gizmo transformation state changes. ```APIDOC ## OnGizmoStateChanged ### Description Blueprint-overridable event called when the gizmo transformation state changes. ### Parameters - **GizmoType** (ETransformationType) - Required - The type of transformation gizmo. - **bTransformInProgress** (bool) - Required - Whether the transformation is currently active. - **Domain** (ETransformationDomain) - Required - The transformation domain. ``` -------------------------------- ### ServerCloneSelected Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Server RPC to clone selected actors with network replication. ```APIDOC ## ServerCloneSelected ### Description Server RPC to clone selected actors with network replication. ### Parameters #### Request Body - **bSelectNewClones** (bool) - Optional - Whether to select the newly created clones. - **bAppendToList** (bool) - Optional - Whether to append clones to the current selection list. ``` -------------------------------- ### SetComponentBased Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Configures whether the system works with individual components or entire actors. ```APIDOC ## SetComponentBased ### Description Configures whether the system works with individual components or entire actors. ### Parameters - **bIsComponentBased** (bool) - Required - True to select components, false to select actors. ``` -------------------------------- ### Mouse Trace by Channel Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Performs a mouse-based line trace using a single collision channel for selection. Useful for targeting specific types of objects. The `bAppendToList` parameter determines if the selection should be additive or replace the current selection. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") bool MouseTraceByChannel( float TraceDistance, TEnumAsByte TraceChannel, TArray IgnoredActors, bool bAppendToList = false ); ``` ```cpp // Example: Simple selection using visibility channel void AMyEditorPawn::SelectWithVisibilityChannel() { TArray IgnoredActors; IgnoredActors.Add(this); bool bSuccess = MouseTraceByChannel( 15000.0f, ECollisionChannel::ECC_Visibility, IgnoredActors, false ); } ``` -------------------------------- ### ClearDomain API and Usage Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Signals the end of a transformation operation by clearing the current domain. Call this when input events like mouse release occur. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") void ClearDomain(); // Example: End transformation on mouse release void AMyEditorPawn::OnLeftMouseReleased() { ClearDomain(); UE_LOG(LogTemp, Log, TEXT("Transformation ended")); } ``` -------------------------------- ### CloneSelected Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Creates copies of all currently selected actors or components. ```APIDOC ## CloneSelected ### Description Creates copies of all currently selected actors or components. ### Parameters - **bSelectNewClones** (bool) - Optional - Whether to select the newly created clones. - **bAppendToList** (bool) - Optional - Whether to append the clones to the current selection list. ``` -------------------------------- ### SelectComponent Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Directly selects a specific scene component for transformation. ```APIDOC ## SelectComponent ### Description Directly selects a specific scene component for transformation. ### Parameters - **Component** (USceneComponent*) - Required - The component to select. - **bAppendToList** (bool) - Optional - Whether to append to the current selection. ``` -------------------------------- ### Implement Object Focus Behavior Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt This event is called when an object implementing the IFocusableObject interface is selected. Implement this to define custom selection behaviors, such as visual outlines or sounds. ```cpp UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Focusable") void Focus( class ATransformerPawn* Caller, class USceneComponent* Component, bool bComponentBased ); // Example: Custom selection behavior void AMyFocusableActor::Focus_Implementation( ATransformerPawn* Caller, USceneComponent* Component, bool bComponentBased) { // Show selection outline MeshComponent->SetRenderCustomDepth(true); MeshComponent->SetCustomDepthStencilValue(1); // Play selection sound UGameplayStatics::PlaySoundAtLocation(this, SelectionSound, GetActorLocation()); // Show UI widget SelectionWidget->SetVisibility(ESlateVisibility::Visible); } ``` -------------------------------- ### GetCurrentDomain API and Usage Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Checks if a transformation is currently in progress and returns the active domain. Useful for gating input logic. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") ETransformationDomain GetCurrentDomain(bool& TransformInProgress) const; // Example: Check if user is currently transforming void AMyEditorPawn::Tick(float DeltaTime) { Super::Tick(DeltaTime); bool bTransformInProgress; ETransformationDomain Domain = GetCurrentDomain(bTransformInProgress); if (bTransformInProgress) { // Disable other input while transforming DisableCameraMovement(); } else { EnableCameraMovement(); } } ``` -------------------------------- ### GetSelectedComponents Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Retrieves the list of currently selected components and the component currently associated with the gizmo. ```APIDOC ## GetSelectedComponents ### Description Retrieves the list of currently selected components and which component has the gizmo attached. ### Parameters #### Request Body - **outComponentList** (TArray&) - Required - Output array to store selected components. - **outGizmoPlacedComponent** (USceneComponent*&) - Required - Output reference to the component currently holding the gizmo. ``` -------------------------------- ### Perform Replicated Mouse Trace Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Use this function to perform a mouse trace that synchronizes object selection between the server and clients. It requires specifying trace distance and collision channels. ```cpp UFUNCTION(BlueprintCallable, Category = "Replicated Runtime Transformer") void ReplicatedMouseTraceByObjectTypes( float TraceDistance, TArray> CollisionChannels, bool bAppendToList = false ); // Example: Multiplayer object selection void AMyMultiplayerEditorPawn::OnLeftMouseClick() { TArray> Channels; Channels.Add(ECollisionChannel::ECC_WorldDynamic); Channels.Add(ECollisionChannel::ECC_PhysicsBody); // This performs local gizmo trace + server object trace ReplicatedMouseTraceByObjectTypes(10000.0f, Channels, false); } ``` -------------------------------- ### Clone Selected Objects Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Creates copies of selected actors or components. `bSelectNewClones` determines if the new copies are selected, and `bAppendToList` controls whether they are added to the existing selection. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") void CloneSelected(bool bSelectNewClones = true, bool bAppendToList = false); ``` ```cpp // Example: Duplicate selection with Ctrl+D void AMyEditorPawn::OnDuplicatePressed() { // Clone and select the new objects CloneSelected(true, false); UE_LOG(LogTemp, Log, TEXT("Selection duplicated")); } // Example: Clone while dragging (hold Alt and drag) void AMyEditorPawn::OnAltDragStart() { // Clone but keep original selected too CloneSelected(true, true); } ``` -------------------------------- ### MouseTraceByObjectTypes Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Performs a mouse-based line trace to select objects or interact with the gizmo using collision object types. ```APIDOC ## MouseTraceByObjectTypes ### Description Performs a mouse-based line trace to select objects or interact with the gizmo using collision object types. ### Method BlueprintCallable ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **TraceDistance** (float) - Required - The maximum distance for the line trace. - **CollisionChannels** (TArray>) - Required - An array of collision channels to trace against. - **IgnoredActors** (TArray) - Required - An array of actors to ignore during the trace. - **bAppendToList** (bool) - Optional - If true, appends to the current selection; otherwise, replaces it. Defaults to false. ### Request Example ```cpp TArray> Channels; Channels.Add(ECollisionChannel::ECC_WorldStatic); Channels.Add(ECollisionChannel::ECC_WorldDynamic); TArray IgnoredActors; IgnoredActors.Add(this); MouseTraceByObjectTypes(10000.0f, Channels, IgnoredActors, false); ``` ### Response #### Success Response (200) - **Return Value** (bool) - True if the trace hit something, false otherwise. #### Response Example ```json { "Return Value": true } ``` ``` -------------------------------- ### MouseTraceByProfile Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Performs a mouse-based line trace using a named collision profile. ```APIDOC ## MouseTraceByProfile ### Description Performs a mouse-based line trace using a named collision profile. ### Method BlueprintCallable ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **TraceDistance** (float) - Required - The maximum distance for the line trace. - **ProfileName** (const FName&) - Required - The name of the collision profile to use for the trace. - **IgnoredActors** (TArray) - Required - An array of actors to ignore during the trace. - **bAppendToList** (bool) - Optional - If true, appends to the current selection; otherwise, replaces it. Defaults to false. ### Request Example ```cpp TArray IgnoredActors; MouseTraceByProfile(10000.0f, FName("SelectableObjects"), IgnoredActors, false); ``` ### Response #### Success Response (200) - **Return Value** (bool) - True if the trace hit something, false otherwise. #### Response Example ```json { "Return Value": true } ``` ``` -------------------------------- ### Apply Networked Transform Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Applies a transformation on the server that is reliably multicast to all clients. Use this for networked transformations, ensuring consistency across all connected players. ```cpp UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable, Category = "Replicated Runtime Transformer") void ServerApplyTransform(const FTransform& DeltaTransform); // Example: Apply transform from client through server void AMyMultiplayerEditorPawn::ApplyNetworkedTransform(const FTransform& Delta) { if (HasAuthority()) { // We're the server, apply directly ApplyDeltaTransform(Delta); } else { // We're a client, send to server ServerApplyTransform(Delta); } } ``` -------------------------------- ### Clone Selected Actors Over Network Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Initiates a server RPC to clone selected actors, with options to select the new clones and append them to the current selection. This is used for networked duplication of actors. ```cpp UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable, Category = "Replicated Runtime Transformer") void ServerCloneSelected(bool bSelectNewClones = true, bool bAppendToList = false); // Example: Networked duplication void AMyMultiplayerEditorPawn::OnDuplicatePressed() { if (HasAuthority()) { CloneSelected(true, false); } else { ServerCloneSelected(true, false); } } ``` -------------------------------- ### ReplicatedMouseTraceByObjectTypes Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Performs a replicated mouse trace that syncs selection across server and clients. ```APIDOC ## ReplicatedMouseTraceByObjectTypes ### Description Performs a replicated mouse trace that syncs selection across server and clients. ### Parameters #### Request Body - **TraceDistance** (float) - Required - The distance to trace. - **CollisionChannels** (TArray>) - Required - The collision channels to trace against. - **bAppendToList** (bool) - Optional - Whether to append the result to the existing selection list. ``` -------------------------------- ### UpdateTransform API and Usage Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Calculates transformation based on ray input. Intended for use in custom input scenarios like VR where a PlayerController is not used. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") FTransform UpdateTransform( const FVector& LookingVector, const FVector& RayOrigin, const FVector& RayDirection ); // Example: Manual transform update for VR or custom input void AMyVREditorPawn::Tick(float DeltaTime) { Super::Tick(DeltaTime); if (bIsTransforming) { // Get VR controller data FVector ControllerLocation = GetMotionControllerLocation(); FVector ControllerForward = GetMotionControllerForward(); FVector HeadForward = GetHeadMountedDisplayForward(); FTransform DeltaTransform = UpdateTransform( HeadForward, ControllerLocation, ControllerForward ); // DeltaTransform contains the change applied this frame } } ``` -------------------------------- ### SelectMultipleActors C++ Function Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Selects multiple actors at once by adding all their root components to the selection. Use 'bAppendToList' to add to the current selection. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") void SelectMultipleActors(const TArray& Actors, bool bAppendToList = false); ``` ```cpp // Example: Box selection of multiple actors void AMyEditorPawn::BoxSelectActors(const FBox& SelectionBox) { TArray AllActors; UGameplayStatics::GetAllActorsOfClass(GetWorld(), AActor::StaticClass(), AllActors); TArray ActorsInBox; for (AActor* Actor : AllActors) { if (SelectionBox.IsInside(Actor->GetActorLocation())) { ActorsInBox.Add(Actor); } } SelectMultipleActors(ActorsInBox, false); UE_LOG(LogTemp, Log, TEXT("Selected %d actors"), ActorsInBox.Num()); } ``` -------------------------------- ### Filter Selectable Objects Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Blueprint-overridable function to define selection criteria. Implement this to control which actors or components can be selected based on tags, classes, or other properties. ```cpp UFUNCTION(BlueprintNativeEvent, Category = "Runtime Transformer") bool ShouldSelect(AActor* OwnerActor, class USceneComponent* Component); ``` ```cpp // Example: Only allow selection of actors with a specific tag bool AMyEditorPawn::ShouldSelect_Implementation(AActor* OwnerActor, USceneComponent* Component) { // Only allow selection of actors tagged as "Editable" if (OwnerActor && OwnerActor->Tags.Contains(FName("Editable"))) { return true; } // Also allow selection of actors of a specific class if (OwnerActor && OwnerActor->IsA(AMyEditableActor::StaticClass())) { return true; } return false; } ``` -------------------------------- ### Determine Transformation Domain Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Use this to identify which gizmo component was interacted with to trigger specific axis or plane logic. ```cpp UFUNCTION(BlueprintCallable, Category = "Gizmo") ETransformationDomain GetTransformationDomain(class USceneComponent* ComponentHit) const; // Example: Check which part of gizmo was hit void AMyCustomGizmo::OnGizmoHit(USceneComponent* HitComponent) { ETransformationDomain Domain = GetTransformationDomain(HitComponent); switch (Domain) { case ETransformationDomain::TD_X_Axis: HighlightXAxis(); break; case ETransformationDomain::TD_Y_Axis: HighlightYAxis(); break; case ETransformationDomain::TD_Z_Axis: HighlightZAxis(); break; case ETransformationDomain::TD_XY_Plane: HighlightXYPlane(); break; } } ``` -------------------------------- ### IFocusableObject::Focus Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Called when an object implementing this interface is selected. ```APIDOC ## IFocusableObject::Focus ### Description Called when an object implementing this interface is selected. ### Parameters #### Request Body - **Caller** (ATransformerPawn*) - Required - The pawn initiating the focus. - **Component** (USceneComponent*) - Required - The component being focused. - **bComponentBased** (bool) - Required - Whether the focus is component-based. ``` -------------------------------- ### Handle Component Selection Changes Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Blueprint-overridable event called when a component's selection state changes. Useful for highlighting selected components or updating UI elements. ```cpp UFUNCTION(BlueprintNativeEvent, Category = "Runtime Transformer") void OnComponentSelectionChange( class USceneComponent* Component, bool bSelected, bool bImplementsUFocusable ); ``` ```cpp // Example: Highlight selected objects void AMyEditorPawn::OnComponentSelectionChange_Implementation( USceneComponent* Component, bool bSelected, bool bImplementsUFocusable) { if (!bImplementsUFocusable) { // Apply custom highlight for objects without IFocusableObject UPrimitiveComponent* Primitive = Cast(Component); if (Primitive) { Primitive->SetRenderCustomDepth(bSelected); Primitive->SetCustomDepthStencilValue(bSelected ? 1 : 0); } } } ``` -------------------------------- ### TraceByObjectTypes Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Performs a line trace between two world-space points using collision object types. ```APIDOC ## TraceByObjectTypes ### Description Performs a line trace between two world-space points using collision object types. Useful when not using mouse input. ### Parameters - **StartLocation** (FVector) - Required - The starting point of the trace. - **EndLocation** (FVector) - Required - The ending point of the trace. - **CollisionChannels** (TArray>) - Required - The collision channels to check against. - **IgnoredActors** (TArray) - Required - List of actors to ignore during the trace. - **bAppendToList** (bool) - Optional - Whether to append to the existing list. ### Response - **bool** - Returns true if the trace hits an object. ``` -------------------------------- ### ReplicateFinishTransform Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Completes a networked transformation operation, syncing final state to all clients. ```APIDOC ## ReplicateFinishTransform ### Description Completes a networked transformation operation, syncing final state to all clients. ``` -------------------------------- ### Implement OnNewTransformation Event Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Override this function to handle per-frame transformation updates and apply custom constraints or UI logic. ```cpp UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Focusable") void OnNewTransformation( class ATransformerPawn* Caller, class USceneComponent* Component, const FTransform& NewTransform, bool bComponentBased ); // Example: Custom transformation handling void AMyFocusableActor::OnNewTransformation_Implementation( ATransformerPawn* Caller, USceneComponent* Component, const FTransform& NewTransform, bool bComponentBased) { // Update position preview UI FVector NewLocation = GetActorLocation() + NewTransform.GetLocation(); PositionText->SetText(FText::FromString( FString::Printf(TEXT("X: %.1f Y: %.1f Z: %.1f"), NewLocation.X, NewLocation.Y, NewLocation.Z) )); // Apply custom constraints if (bRestrictToGround) { // Override Z movement to keep on ground FVector ConstrainedLocation = NewLocation; ConstrainedLocation.Z = GroundHeight; SetActorLocation(ConstrainedLocation); } } ``` -------------------------------- ### MouseTraceByChannel Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Performs a mouse-based line trace using a single collision channel for selection. ```APIDOC ## MouseTraceByChannel ### Description Performs a mouse-based line trace using a single collision channel for selection. ### Method BlueprintCallable ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **TraceDistance** (float) - Required - The maximum distance for the line trace. - **TraceChannel** (TEnumAsByte) - Required - The single collision channel to trace against. - **IgnoredActors** (TArray) - Required - An array of actors to ignore during the trace. - **bAppendToList** (bool) - Optional - If true, appends to the current selection; otherwise, replaces it. Defaults to false. ### Request Example ```cpp TArray IgnoredActors; IgnoredActors.Add(this); MouseTraceByChannel(15000.0f, ECollisionChannel::ECC_Visibility, IgnoredActors, false); ``` ### Response #### Success Response (200) - **Return Value** (bool) - True if the trace hit something, false otherwise. #### Response Example ```json { "Return Value": true } ``` ``` -------------------------------- ### Manage Selection Operations Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Commands for duplicating or deleting the currently selected actors. ```cpp void AMyRuntimeEditorPawn::DuplicateSelection() { CloneSelected(true, false); GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Blue, TEXT("Selection Duplicated")); } void AMyRuntimeEditorPawn::DeleteSelection() { DeselectAll(true); GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Red, TEXT("Selection Deleted")); } ``` -------------------------------- ### Set Transformation Progress State Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Manually toggle the transformation state to broadcast changes to listeners. ```cpp UFUNCTION(BlueprintCallable, Category = "Gizmo") void SetTransformProgressState(bool bInProgress, ETransformationDomain CurrentDomain); // Example: Manually control transform state void AMyCustomGizmo::StartCustomTransformation(ETransformationDomain Domain) { SetTransformProgressState(true, Domain); // Broadcast state change OnGizmoStateChange.Broadcast(GetGizmoType(), true, Domain); } ``` -------------------------------- ### ServerDeselectAll Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Server RPC to clear selection across all clients. ```APIDOC ## ServerDeselectAll ### Description Server RPC to clear selection across all clients. ### Parameters #### Request Body - **bDestroySelected** (bool) - Required - Whether to destroy the selected objects upon deselection. ``` -------------------------------- ### SelectComponent C++ Function Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Directly selects a specific scene component for transformation. Ensure component-based mode is enabled before using this function. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") void SelectComponent(class USceneComponent* Component, bool bAppendToList = false); ``` ```cpp // Example: Select specific components within an actor void AMyEditorPawn::SelectActorComponents(AActor* TargetActor) { // Get all static mesh components TArray MeshComponents; TargetActor->GetComponents(MeshComponents); // Must enable component-based mode first SetComponentBased(true); for (int32 i = 0; i < MeshComponents.Num(); i++) { SelectComponent(MeshComponents[i], i > 0); // Append after first selection } } ``` -------------------------------- ### ApplyDeltaTransform API and Usage Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Applies a specific delta transform to all currently selected objects. Useful for programmatic movement or rotation. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") void ApplyDeltaTransform(const FTransform& DeltaTransform); // Example: Programmatic transformation void AMyEditorPawn::MoveSelectionUp(float Distance) { FTransform DeltaTransform; DeltaTransform.SetLocation(FVector(0.0f, 0.0f, Distance)); ApplyDeltaTransform(DeltaTransform); } void AMyEditorPawn::RotateSelection(float YawDegrees) { FTransform DeltaTransform; DeltaTransform.SetRotation(FQuat(FRotator(0.0f, YawDegrees, 0.0f))); ApplyDeltaTransform(DeltaTransform); } ``` -------------------------------- ### TraceByObjectTypes C++ Function Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Performs a line trace between two world-space points using specified collision object types. Useful when not relying on mouse input. ```cpp UFUNCTION(BlueprintCallable, Category = "Runtime Transformer") bool TraceByObjectTypes( const FVector& StartLocation, const FVector& EndLocation, TArray> CollisionChannels, TArray IgnoredActors, bool bAppendToList = false ); ``` ```cpp // Example: VR controller-based selection void AMyVREditorPawn::SelectWithVRController(const FVector& ControllerLocation, const FVector& ControllerForward) { FVector StartLocation = ControllerLocation; FVector EndLocation = ControllerLocation + (ControllerForward * 5000.0f); TArray> Channels; Channels.Add(ECollisionChannel::ECC_WorldStatic); Channels.Add(ECollisionChannel::ECC_WorldDynamic); TArray IgnoredActors; IgnoredActors.Add(this); bool bSelected = TraceByObjectTypes(StartLocation, EndLocation, Channels, IgnoredActors, false); } ``` -------------------------------- ### Scale Gizmo Scene Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Adjusts the gizmo scale based on camera distance to maintain a consistent visual size. ```cpp void ScaleGizmoScene( const FVector& ReferenceLocation, const FVector& ReferenceLookDirection, float FieldOfView = 90.f ); // Example: Update gizmo scale each frame void AMyCustomGizmo::Tick(float DeltaTime) { Super::Tick(DeltaTime); if (APlayerController* PC = GetWorld()->GetFirstPlayerController()) { if (APlayerCameraManager* CameraManager = PC->PlayerCameraManager) { FVector CameraLocation = CameraManager->GetCameraLocation(); FVector CameraForward = CameraManager->GetCameraRotation().Vector(); float FOV = CameraManager->GetFOVAngle(); ScaleGizmoScene(CameraLocation, CameraForward, FOV); } } } ``` -------------------------------- ### ApplyDeltaTransform Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Manually applies a specific delta transform to all currently selected objects. ```APIDOC ## ApplyDeltaTransform ### Description Manually applies a delta transform to all selected objects. ### Parameters #### Request Body - **DeltaTransform** (FTransform) - Required - The transformation to apply to the selection. ``` -------------------------------- ### SelectActor Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Directly selects an actor by adding its root component to the selection list. ```APIDOC ## SelectActor ### Description Directly selects an actor by adding its root component to the selection list. ### Parameters - **Actor** (AActor*) - Required - The actor to select. - **bAppendToList** (bool) - Optional - Whether to append to the current selection. ``` -------------------------------- ### Switch Transformation Modes Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Functions to update the active transformation type and provide visual feedback via on-screen debug messages. ```cpp void AMyRuntimeEditorPawn::SwitchToTranslation() { SetTransformationType(ETransformationType::TT_Translation); GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Green, TEXT("Translation Mode")); } void AMyRuntimeEditorPawn::SwitchToRotation() { SetTransformationType(ETransformationType::TT_Rotation); GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Green, TEXT("Rotation Mode")); } void AMyRuntimeEditorPawn::SwitchToScale() { SetTransformationType(ETransformationType::TT_Scale); GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Green, TEXT("Scale Mode")); } ``` -------------------------------- ### Replicate Finish Transformation Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Call this function to finalize a networked transformation operation. It ensures the final state of the transformation is synchronized across all clients. ```cpp UFUNCTION(BlueprintCallable, Category = "Replicated Runtime Transformer") void ReplicateFinishTransform(); // Example: End multiplayer transformation on mouse release void AMyMultiplayerEditorPawn::OnLeftMouseReleased() { ReplicateFinishTransform(); } ``` -------------------------------- ### GetCurrentDomain Source: https://context7.com/xyahh/ue4runtimetransformer/llms.txt Returns the active transformation domain and indicates if a transformation is currently in progress. ```APIDOC ## GetCurrentDomain ### Description Returns the current transformation domain and whether a transformation is in progress. ### Parameters #### Request Body - **TransformInProgress** (bool&) - Required - Output boolean indicating if a transformation is active. ### Response #### Success Response (200) - **Return** (ETransformationDomain) - The current transformation domain. ```