I have been trying to wrap my head around K2 nodes and how to make use of them properly to implement into my game, I have been running into an issue with a node for SeamlessTravelActorList, to make it so that my “elevators” are permanent in the game, as I rely on them for functions in the different levels.
I struggled quite a bit to get the node to show up to begin with, and now it does not really function as I want it to.
The one I aimed to create, was the nodes and functionality from this [Feature] Allow GetSeamlessTravelActorList to be hooked in blueprint GameMode
My node current looks like this.
And my code looks like this; Can someone enlighten me as to what I am doing wrong.
/Amoe
.cpp
#include "MyGameModeBase.h"
// #include "GameFramework/Actor.h"
// #include "Engine/World.h"
void AMyGameModeBase::GetSeamlessTravelActorList(bool bToTransition, TArray<AActor*>& ActorList)
{
Super::GetSeamlessTravelActorList(bToTransition, ActorList);
// Ensure to call the implementation directly instead of pointer checking
K2_OnGetSeamlessTravelActorList(bToTransition, ActorList);
}
void AMyGameModeBase::K2_OnGetSeamlessTravelActorList_Implementation(bool bToTransition, TArray<AActor*>& ActorList)
{
// Debug log to ensure the function is called
UE_LOG(LogTemp, Warning, TEXT("K2_OnGetSeamlessTravelActorList is called"));
// Example: Add a specific actor to the list (replace with your actual actor reference or logic)
AActor* ExampleActor = GetWorld()->SpawnActor<AActor>();
if (ExampleActor)
{
ActorList.Add(ExampleActor);
}
}
.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "MyGameModeBase.generated.h"
/**
*
*/
UCLASS()
class CATSRMAZE_API AMyGameModeBase : public AGameModeBase
{
GENERATED_BODY()
public:
virtual void GetSeamlessTravelActorList(bool bToTransition, TArray<AActor*>& ActorList) override;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "SeamlessTravel")
void K2_OnGetSeamlessTravelActorList(bool bToTransition, TArray<AActor*>& ActorList);
void GetSeamlessTravelActorList_Implementation(bool bToTransition, TArray<AActor*>& ActorList);