Download

C++ simple ATriggerVolume* declaration cannot set the triggervolume in the editor

Within my ActorComponent I’ve declared:
ATriggerVolume* TriggeringVolume;
and compiled, all fine there.

However when dragging a TriggerVolume into the scene, under the ActorComponent’s editor properties, going to assign the TriggeringVolume to the TriggerVolume, although the property recognizes the TriggerVolume as a selectable option the property remains ‘none’

I don’t know how to assign the TriggerVolume in the scene to the ATriggerVolume* TriggeringVolume declaration in the ActorComponent.
I mean, under the list of possible objects the TriggerVolume in the scene is recognized as a possible object, the property remains ‘none’ once assigned.
This is the same as with the spyglass to directly click the object in the scene.
I can probably assign a TriggerVolume to the declaration through code but still practicing and want this to remain simple for now.

Anyone know?

Tested:
Unreal Engine version 4.22.3 - Works just as expected, getting assigned via the editor

However Unreal Engine version 4.26.1 - I cannot get the ATriggerVolume* declaration to be assigned via the editor (haven’t tried through programming yet)

Can you show us the code?

Unreal Engine v4.22.3
.h file



#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine/TriggerVolume.h"
#include "TestFunctionality.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MYPROJECT_API UTestFunctionality : public UActorComponent
{
    GENERATED_BODY()
public:
    // Sets default values for this component's properties
    UTestFunctionality();
protected:
    // Called when the game starts
    virtual void BeginPlay() override;
public:
    // Called every frame
    virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
private:    
    UPROPERTY(EditAnywhere, Category="Functionality")
    ATriggerVolume* TriggeringArea;        
};


.cpp file:



#include "TestFunctionality.h"

// Sets default values for this component's properties
UTestFunctionality::UTestFunctionality()
    : TriggeringArea{nullptr}
{
    // Set this component to be initialized when the game starts, and to be ticked every frame.
    PrimaryComponentTick.bCanEverTick = true;
}

// Called when the game starts
void UTestFunctionality::BeginPlay()
{
    Super::BeginPlay();    
}

// Called every frame
void UTestFunctionality::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}


Unreal Engine v4.26.1
.h file:



#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine/TriggerVolume.h"
#include "TestFunctionality.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class TUTORIALPROJECT_API UTestFunctionality : public UActorComponent
{
    GENERATED_BODY()
public:
    // Sets default values for this component's properties
    UTestFunctionality();
protected:
    // Called when the game starts
    virtual void BeginPlay() override;
public:
    // Called every frame
    virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
private:
    UPROPERTY(EditAnywhere, Category="Functionality")
    ATriggerVolume* TriggeringArea;        
};


.cpp file:



#include "TestFunctionality.h"

// Sets default values for this component's properties
UTestFunctionality::UTestFunctionality()
    : TriggeringArea{nullptr}
{
    // Set this component to be initialized when the game starts, and to be ticked every frame.
    PrimaryComponentTick.bCanEverTick = true;
}

// Called when the game starts
void UTestFunctionality::BeginPlay()
{
    Super::BeginPlay();    
}

// Called every frame
void UTestFunctionality::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}


//Note:
Essentially the same code, besides project naming convention.
with engine v4.22.3 the ATriggerVolume
declaration is assignable, and not assignable with engine v4.26.1, through the editor.
I haven’t tried programatically, at some point that’ll happen, but I’m still learning and that’s probably chapter 26 and I’m on chapter 3.
*

Tested:
Okay. I don’t know. I just updated/verified the engine installations, before that; assignment of ATriggerVolume* worked, now doesn’t work.

I guess the better question now is how to assign a triggervolume in the scene to a ATriggerVolume* declaration through C++?

Okay, so odd thing here: when organizing the content browser into individual folders, the assignment stops working, however when all the assets/textures/materials/etc are in the default ‘content’ folder, now assignment works (at least in v4.22.3).

hahahehumm maybe the issue here is how the folders are organized, I–I don’t know.

**Fixed:
Solution:

don’t use


'('


')'

or


'-'

in the folder naming convention of the content browser!**