Hey guys,
I’m trying to do something really simple, I have a struct with some component that I create in my constructor and attach it to the root. No problem so far, everything is created and moved in the origin of my Root. But When I go into my blueprint to move those component manually, I can’t access them.
USTRUCT(BlueprintType)
struct XROAD_API FXRoadVehicleSeat
{
GENERATED_USTRUCT_BODY()
public:
FXRoadVehicleSeat() {}
FXRoadVehicleSeat(UBoxComponent* LocalDoorInteractionCollision,
UArrowComponent* LocalExitVehicleArrow,
EDoorPosition LocalDoorPosition,
FName LocalSocketName,
AXRoadPedestrian * LocalPedestrianOnTheSeat = NULL)
{
DoorInteractionCollision = LocalDoorInteractionCollision;
ExitVehicleArrow = LocalExitVehicleArrow;
DoorPosition = LocalDoorPosition;
SocketName = LocalSocketName;
PedestrianOnTheSeat = LocalPedestrianOnTheSeat;
}
public:
UPROPERTY(BlueprintReadWrite, VisibleAnywhere, meta = (AllowPrivateAccess = "true"), Category = "XROAD|Vehicle|Seats")
UBoxComponent * DoorInteractionCollision;
UPROPERTY(BlueprintReadWrite, VisibleAnywhere, meta = (AllowPrivateAccess = "true"), Category = "XROAD|Vehicle|Seats")
UArrowComponent * ExitVehicleArrow;
UPROPERTY(EditAnywhere, meta = (AllowPrivateAccess = "true"), Category = "XROAD|Vehicle|Seats")
EDoorPosition DoorPosition;
UPROPERTY(EditAnywhere, meta = (AllowPrivateAccess = "true"), Category = "XROAD|Vehicle|Seats")
FName SocketName;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "XROAD|Vehicle|Doors")
AXRoadPedestrian * PedestrianOnTheSeat;
UPROPERTY(BlueprintReadOnly, Category = "XROAD|Vehicle|Seats")
bool bIsDriverSeat;
};
This is my stucture containing my two component I want to modify.
// Seats properties
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "XROAD|Vehicle|Interaction")
TArray<FXRoadVehicleSeat> VehicleSeats;
Here is my declaration of FXRoadVehicleSeat
AXRoadVehicle4W::AXRoadVehicle4W(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
// Camera Setup
// Create our FPS Arm spring component
FPSCameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("FPSCameraSpringArm"));
FPSCameraSpringArm->SetupAttachment(RootComponent);
FPSCameraSpringArm->SetRelativeLocationAndRotation(FVector(0.0f, -32.0f, 128.0f), FRotator(0.0f, -5.0f, 0.0f));
FPSCameraSpringArm->TargetArmLength = 0.0f;
FPSCameraSpringArm->bEnableCameraLag = false;
// Create our TPS Arm spring component
TPSCameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("TPSCameraSpringArm"));
TPSCameraSpringArm->SetupAttachment(RootComponent);
TPSCameraSpringArm->SetRelativeLocationAndRotation(FVector(2.6f, 0.0f, 130.0f), FRotator(-15.0f, 0.0f, 0.0f));
TPSCameraSpringArm->TargetArmLength = 400.0f;
TPSCameraSpringArm->bEnableCameraLag = false;
// Create the camera and attach it to the fps arm
VehicleCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("GameCamera"));
VehicleCamera->SetupAttachment(FPSCameraSpringArm, USpringArmComponent::SocketName);
VehicleCamera->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, 0.0f), FRotator(0.0f, 0.0f, 0.0f));
// Setup Vehicle Seats
NumberOfSeats = 4;
for (int i = 0; i < NumberOfSeats; ++i)
{
// Door Collision
UBoxComponent * Collision = CreateDefaultSubobject<UBoxComponent>(FName(*FString(GETENUMSTRING("EDoorPosition", (EDoorPosition)i) + "_Collision")));
Collision->SetupAttachment(RootComponent);
// Exit Arrow for the pedestrian
UArrowComponent * ExitVehicleArrow = CreateDefaultSubobject<UArrowComponent>(*FString("ExitArrow_" + FString::FromInt(i)));
ExitVehicleArrow->SetupAttachment(Collision);
VehicleSeats.Add(FXRoadVehicleSeat(Collision,
ExitVehicleArrow,
(EDoorPosition)i,
FName(*(GETENUMSTRING("EDoorPosition", (EDoorPosition)i))),
NULL));
}
// Setup Anim Instance
if (Mesh != NULL)
{
AnimationVehicle = Cast<UDcxVehicleAnimInstance>(Mesh->GetAnimInstance());
if (AnimationVehicle != NULL)
{
AnimationVehicle->SteeringWheelAngle = 0.0f;
}
}
}
And finally my constructor where I initialize every Component.
Here is the result of this code. I still can’t access them, but if I’m putting them outside a struct It’s working as intended, I can modify them manually. So my question is what I am doing wrong, I put VisibleAnywhere or EditAnywhere for my component and even BlueprintReadWrite but I still can’t have any control over them in my Viewport or details panel.
Any feedback is welcome! Thanks!