TArray not working

After fighting with the tick not ticking all morning, I finally got that sorted out. The correct header files are attached.

I have tried Updating the project from the editor, closing and rebuilding from VS Code, adding and removing the component.

CPP

// Fill out your copyright notice in the Description page of Project Settings.


#include "TriggerCompononet.h"

UTriggerCompononet::UTriggerCompononet()
{  
    // Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	// ...
}

void UTriggerCompononet::BeginPlay()
{
    Super::BeginPlay();
   
}

void UTriggerCompononet::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

    UE_LOG(LogTemp, Display, TEXT("TickComponent called"));

    TArray<AActor *> OverlappingActors;
    GetOverlappingActors(OverlappingActors);

    if(OverlappingActors.Num() > 0)
    {   
        FString ActorName = OverlappingActors[0]->GetActorNameOrLabel();
        UE_LOG(LogTemp, Error, TEXT("Overlapping with %d actors"), *ActorName);
    }

}

HEADER

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/BoxComponent.h"
#include "TriggerCompononet.generated.h"

/**
 * 
 */
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class GDTV_CRYPTGAME_API UTriggerCompononet : public UBoxComponent
{
	GENERATED_BODY()

public:
	// Sets default values for this component's properties
	UTriggerCompononet();
	
protected:
	// Called when the game starts
	virtual void BeginPlay() override;
	
public:
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
	
};

In what sense is it not working?

Sorry, I have only just gotten back to work on this. For some reason I have yet to figure out, Unreal keeps disassociating the components. I ended up having to delete them and add them back. This is still an ongoing issue. But because Unreal wasn’t seeing them, the arrays weren’t firing either.

Could you elaborate on what you mean by this?

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms