Announcement

Collapse
No announcement yet.

Actor Component will not tick

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Actor Component will not tick

    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:

    Code:
    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:

    Code:
    #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

    #2
    Remove this from the constructor:

    Code:
    this->SetComponentTickEnabled(true);
    And add this:

    Code:
    PrimaryComponentTick.bCanEverTick = true;
    PrimaryComponentTick.bStartWithTickEnabled = true;

    Comment


      #3
      Ok I have spent so many real "ticks" (120 minutes to be precise) to figure this. I tried all the permutations of
      Code:
          PrimaryComponentTick.bCanEverTick = true;
          RegisterAllComponentTickFunctions(true);
          PrimaryComponentTick.bStartWithTickEnabled = true;
          this->SetComponentTickEnabled(true);
          bTickInEditor = true;
      nothing works. What more, when I include
      Code:
      RegisterComponentTickFunctions(true);
      Engine crashes with the error spit
      Code:
      LoginId:noiwillnottellyou
      EpicAccountId:
      
      Assertion failed: GTestRegisterComponentTickFunctions == __null [File:/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/Components/ActorComponent.cpp] [Line: 918]
      
      libUE4Editor-Core.so!FUnixErrorOutputDevice::Serialize(char16_t const*, ELogVerbosity::Type, FName const&) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Core/Private/Unix/UnixErrorOutputDevice.cpp:70]
      libUE4Editor-Core.so!FOutputDevice::LogfImpl(char16_t const*, ...) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Core/Private/Misc/OutputDevice.cpp:71]
      libUE4Editor-Core.so!FDebug::AssertFailed(char const*, char const*, int, char16_t const*, ...) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Core/Private/Misc/AssertionMacros.cpp:440]
      libUE4Editor-Core.so!FDebug::CheckVerifyFailedImpl(char const*, char const*, int, char16_t const*, ...) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Core/Private/Misc/AssertionMacros.cpp:416]
      libUE4Editor-Engine.so!UActorComponent::RegisterComponentWithWorld(UWorld*) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/Components/ActorComponent.cpp:1022]
      libUE4Editor-Engine.so!AActor::IncrementalRegisterComponents(int) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/Actor.cpp:4314]
      libUE4Editor-Engine.so!AActor::RegisterAllComponents() [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/Actor.cpp:4254]
      libUE4Editor-Engine.so!AActor::PostSpawnInitialize(FTransform const&, AActor*, APawn*, bool, bool, bool) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/Actor.cpp:3017]
      libUE4Editor-Engine.so!UWorld::SpawnActor(UClass*, FTransform const*, FActorSpawnParameters const&) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/LevelActor.cpp:476]
      libUE4Editor-Engine.so!UWorld::SpawnActor(UClass*, FVector const*, FRotator const*, FActorSpawnParameters const&) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/LevelActor.cpp:301]
      libUE4Editor-Engine.so!UWorld::InternalGetDefaultPhysicsVolume() const [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/World.cpp:4324]
      libUE4Editor-Engine.so!UWorld::InitWorld(UWorld::InitializationValues) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/World.cpp:1294]
      libUE4Editor-Engine.so!UWorld::InitializeNewWorld(UWorld::InitializationValues) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/World.cpp:1505]
      libUE4Editor-Engine.so!UWorld::CreateWorld(EWorldType::Type, bool, FName, UPackage*, bool, ERHIFeatureLevel::Type) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/World.cpp:1588]
      libUE4Editor-Engine.so!UEngine::Init(IEngineLoop*) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:1460]
      libUE4Editor-UnrealEd.so!UEditorEngine::InitEditor(IEngineLoop*) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Editor/UnrealEd/Private/EditorEngine.cpp:584]
      libUE4Editor-UnrealEd.so!UEditorEngine::Init(IEngineLoop*) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Editor/UnrealEd/Private/EditorEngine.cpp:822]
      libUE4Editor-UnrealEd.so!UUnrealEdEngine::Init(IEngineLoop*) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Editor/UnrealEd/Private/UnrealEdEngine.cpp:73]
      UE4Editor!FEngineLoop::Init() [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:3265]
      libUE4Editor-UnrealEd.so!EditorInit(IEngineLoop&) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Editor/UnrealEd/Private/UnrealEdGlobals.cpp:75]
      UE4Editor!GuardedMain(char16_t const*) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Launch/Private/Launch.cpp:150]
      libUE4Editor-UnixCommonStartup.so!CommonUnixMain(int, char**, int (*)(char16_t const*)) [/home/the_cowboy/unrealworks/UnrealEngine/Engine/Source/Runtime/Unix/UnixCommonStartup/Private/UnixCommonStartup.cpp:243]
      libc.so.6!__libc_start_main(+0xef)
      UE4Editor!_start()
      I am inheriting UBrainComponent, https://github.com/EpicGames/UnrealE...ainComponent.h
      https://ravimohan.net/
      https://github.com/ravimohan1991

      Comment


        #4
        Yay! With 55 more minutes worth of "ticks" I found the solution. The idea is to register the component
        Code:
        RegisterComponent();
        besides setting
        Code:
        PrimaryComponentTick.bCanEverTick = true;
        Furthermore make sure to instantiate the UActorComponent in the following fashion
        Code:
        BrainComponent = NewObject<UMAIBrainComponent>(someactorpointer);
        Then the UActorComponent WILL tick!
        Last edited by The-Cowboy; 07-06-2019, 09:22 PM.
        https://ravimohan.net/
        https://github.com/ravimohan1991

        Comment

        Working...
        X