Hi all,
Having a very unusual problem where one of my components will not tick. It only happens for this one component, and I seem to have set it up the same way as my others.
Any help would be greatly appreciated, it’s a real head-scratcher:
Header:
UCLASS(meta = (BlueprintSpawnableComponent))
class ROGUELIKE_API UDamageZone : public USphereComponent
{
GENERATED_UCLASS_BODY()
public:
//The interval by which to apply damage
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = DamageZone)
float Interval;
UFUNCTION()
void OnBeginOverlap(class UPrimitiveComponent* HitComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
UFUNCTION()
void OnEndOverlap(class UPrimitiveComponent* HitComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
private:
float timeSinceLastTick;
};
Body:
#include "DamageZone.h"
UDamageZone::UDamageZone(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
OnComponentBeginOverlap.AddDynamic(this, &UDamageZone::OnBeginOverlap);
OnComponentEndOverlap.AddDynamic(this, &UDamageZone::OnEndOverlap);
this->SetComponentTickEnabled(true);
}
void UDamageZone::OnBeginOverlap(class UPrimitiveComponent* HitComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
//logic to add character to collection of overlapped characters
}
void UDamageZone::OnEndOverlap(class UPrimitiveComponent* HitComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
//logic to remove character to collection of overlapped characters
}
void UDamageZone::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
timeSinceLastTick += DeltaTime;
//logic to deal damage
}
I’ve removed a lot of the specific implementation logic as it’s irrelevant and didn’t want to spam too much code. This component is attached to an actor made using the blueprint system. The overlaps both work and I can hit breakpoints within them, but the tick function is never called.
I’ve tried calling various functions in the constructor to enable the tick, including the one shown, and none work. I can’t remember the names of the others off the top of my head.
Any help would be greatly appreciated