I cannot change the properties of my CollisionBox in the editor. It says: “Native components are editable when declared as a UProperty in C++.”. But I DID declare it like that.
I did notice though that changing the TriggerShape in the editor requires an editor-restart for it to be visible in the editor… And then I also have all the other components. So If I changed from Box ==> Sphere I see them in the component-window but not in the viewport. After I restart the editor I have both a box and a sphere component and both visible in the viewport…
So something is really wrong. Not even the mobility is correctly set.
All I really want to do is just allow the editor to determine the collision-shape (box/sphere/capsule). That’s it.
My header code:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Waypoint")
UShapeComponent *WaypointArea;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Waypoint")
ETDCollisionShape TriggerShape = ETDCollisionShape::Box;
My cpp code:
void AWaypoint::CreateWPAreaComponent()
{
if (WaypointArea) { WaypointArea->DestroyComponent(); }
switch (TriggerShape)
{
case ETDCollisionShape::Box:
WaypointArea = ConstructObject<UBoxComponent>(UBoxComponent::StaticClass(), this);
break;
case ETDCollisionShape::Capsule:
WaypointArea = ConstructObject<UCapsuleComponent>(UCapsuleComponent::StaticClass(), this);
break;
case ETDCollisionShape::Sphere:
WaypointArea = ConstructObject<USphereComponent>(USphereComponent::StaticClass(), this);
break;
default:
ULibraryObject::LogErrorSafely("Waypoint.cpp", "Missing switch-case.");
}
WaypointArea->AttachTo(RootComponent);
WaypointArea->SetCollisionProfileName("WaypointArea");
WaypointArea->SetMobility(EComponentMobility::Static);
}