Hello there. I’m trying to figure out how to create a blueprint of a class. I’ve followed a few guides, youtube videos and other forum posts on how to do this and although only few of them work, none of them explain the properties we’re meant to include in the functions we create that we want to override. I’m sure I’ve explained this poorly and I hope that by showing you my problem you might understand it further and offer advice.
I have a very basic C++ class (ABaseClass).
My nOnClicked method below however doesn’t have any parameters and I believe this is why I’m receiving errors. I assumed that because when I create the On Clicked event node in blueprint viewer it has no parameters that there should be no parameters in this even either.
UCLASS()
class SIM_LITE_API ABaseClass : public AActor
{
GENERATED_UCLASS_BODY()
/* Simple collision primitive to use as the root component */
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Component)
TSubobjectPtr<USphereComponent> CollisionComponent;
/* Mesh to store the model data */
UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Component)
TSubobjectPtr<UStaticMeshComponent> ModelComponent;
/* Event */
UFUNCTION(BlueprintNativeEvent)
void nOnClicked();
};
ABaseClass::ABaseClass(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
CollisionComponent = PCIP.CreateDefaultSubobject<USphereComponent>(this, "CollisionComponent");
RootComponent = CollisionComponent;
ModelComponent = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, "ModelComponent");
ModelComponent->AttachTo(RootComponent);
ModelComponent->OnClicked.AddDynamic(this, &ABaseClass::nOnClicked);
}
void ABaseClass::nOnClicked_Implementation()
{
}
Thanks for your time.
ABaseClass::ABaseClass(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
CollisionComponent = PCIP.CreateDefaultSubobject<USphereComponent>(this, "CollisionComponent");
RootComponent = CollisionComponent;
ModelComponent = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, "ModelComponent");
ModelComponent->AttachTo(RootComponent);
ModelComponent->OnClicked.AddDynamic(this, &ABaseClass::nOnClicked);
}
void ABaseClass::nOnClicked_Implementation()
{
}
(...) error C2664: 'void TBaseDynamicMulticastDelegate_OneParam<void,UPrimitiveComponent *,FWeakObjectPtr>::__Internal_AddDynamic<ABaseClass>(UserClass *,void (__cdecl ABaseClass::* )(Param1Type),const FString &)' : cannot convert argument 2 from 'void (__cdecl ABaseClass::* )(void)' to 'void (__cdecl ABaseClass::* )(Param1Type)'
1> with
1>
1> UserClass=ABaseClass
1> , Param1Type=UPrimitiveComponent *
1> ]
1> and
1>
1> Param1Type=UPrimitiveComponent *
1> ]
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Thanks for your time.