So I’m going through the Unreal tutorials and I’ve seem to hit a bit of a snag in one of the on your own sections where you have to make a torch (Reference: https://docs.unrealengine.com/latest/INT/Programming/Tutorials/VariablesTimersEvents/4/index.html )
So Here was my plan of attack, Write several “events” in C++ and handle some of the overhead logic in Blueprints
For Reference: (No I don’t know why it didn’t all enter the code block, I apollogize for this mess)
TorchActor.h
UCLASS()
class QUICKSTART_API ATorchActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor’s properties
ATorchActor();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UActorComponent* Fire;
UPROPERTY(EditAnywhere) int32 StartTime;
UPROPERTY(BlueprintReadWrite) int32 BurnTime;
UPROPERTY(EditAnywhere, BlueprintReadOnly) int32 FuelAdd;
UPROPERTY(BlueprintReadOnly) bool isDoused;
UFUNCTION(BlueprintNativeEvent) void AddFuel(int32 FCount);
virtual void AddFuel_Implementation(int32 FCount);
UFUNCTION(BlueprintNativeEvent) void DouseWithWater(); //Call in blueprint
virtual void DouseWithWater_Implementation();
virtual void Burn();
UFUNCTION(BlueprintNativeEvent) void EndBurn();
virtual void EndBurn_Implementation();
FTimerHandle BurnTimerHandle;
};
and TorchActor.cpp
#include "QuickStart.h"
#include "TorchActor.h"
// Sets default values
ATorchActor::ATorchActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
}
// Called when the game starts or when spawned
void ATorchActor::BeginPlay()
{
Super::BeginPlay();
GetWorldTimerManager().SetTimer(BurnTimerHandle,this, &ATorchActor::Burn, 1.0f, true);
}
void ATorchActor::Burn() {
if (BurnTime > 0) {
--BurnTime;
} else {
GetWorldTimerManager().ClearTimer(BurnTimerHandle);
EndBurn();
}
}
void ATorchActor::AddFuel_Implementation(int32 FCount) {
if (!isDoused) {
if (BurnTime == 0) {
GetWorldTimerManager().SetTimer(BurnTimerHandle, this, &ATorchActor::Burn, 1.0f, true); //Reset timer
} else {
BurnTime += FCount;
}
}
}
void ATorchActor::DouseWithWater_Implementation() {
isDoused = true;
BurnTime = 0;
}
void ATorchActor::EndBurn_Implementation() {
}
// Called every frame
void ATorchActor::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
Compiles clean and to me at least seems to make sense (Not that it is any GOOD mind you :P) so far so good!
Everything seems to go to hell in a handbasket when I hit the Blueprint stage, I finally make one but I run into an issue. I can’t seem to actually CALL a C++ function from an input, so I decide to go around it and use event dispatchers.
Then I get this lovely error on the methods I attempt to bind to the event dispatcher:
Signature Error: The selected function/event is not bindable - is the function/event pure or latent?
on both methods I attempt to bind to their respective dispatchers
Anyway here is the entire blueprint for reference.
I haven’t really been able to get much answers one way or another why it’s not working. So my question is, where am I going wrong here? Am I even approaching this right or is there something else “special” that I need to do to get it to behave and in a “testable” state?