Hello. I’m trying to create system which will deal with all interactable objects in my game(ladders, doors etc). The thing is that I have a basic class called AInteractableObject, which is inherited from AActor. Inside this class I created variable: UBoxComponent* m_triggerZone which should represent an interactable zone.
Then I created a AVerticalLadder class which is inherited from AInteractableObject. Then inside the editor I created a BP inherited from AVerticalLadder and also add static mesh component to it.
I expected now that I should be able to edit that trigger zone inside this BP( which is inherited from AInteractableObject ), but I can’t do so.
Is there are any way to do it?
Interactable object class:
UCLASS()
class ROGUEGAME_API AInteractableObject : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AInteractableObject();
protected:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UBoxComponent* m_triggerZone;
};
Ladder class:
UCLASS()
class ROGUEGAME_API AVerticalLadder : public AInteractableObject
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AVerticalLadder();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
Ok, I figured out that I can add an additional variable to the AVerticalLadder class: class UBoxComponent* m_triggerZone2 and assign
m_triggerZone2 = m_triggerZone in the constructor. In this case I can edit m_triggerZone2 in AverticalLadder’s BP. But this solutions looks not very clear from the code side…
Thank you for the answer. It could be the case, but looks like it’s a bug in 4.22 version. I’he tried to do the same in 4.21 and everything is ok - I can edit triggerZone. The only thing, that I can’t move or rotate it, I’m able only to change scale
The other interesting thing, is that if I’ll add a SceneComponent as a root for triggerZone I’m only able to edit this sceneComponent, but not triggerZone anymore. I’ve tried to set bEditableWhenInherited = true for both (scene and trigger) but it changes nothing.
// Sets default values
AInteractableObject::AInteractableObject()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
//m_sceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Scene "));
//m_sceneComponent->bEditableWhenInherited = true;
m_triggerZone = CreateDefaultSubobject<UBoxComponent>(TEXT("Trigger Zone"));
m_triggerZone->bEditableWhenInherited = true;
m_triggerZone->SetBoxExtent(FVector(32.0f, 32.0f, 32.0f));
//m_triggerZone->SetupAttachment(m_sceneComponent);
m_triggerZone->SetupAttachment(RootComponent);
}
Have you used hot reload ? when you’re making changes in the constructor and changing the components, hot reload cannot be trusted, you have to close and re-open the editor