This should be fairly basic, but I’m trying to Spawn a C++ actor, then call a function right after it’s created. A much simplified version of my code is as follows:
Object.h
UCLASS()
class MK1_API AObject : public AActor
{
// Other Things
public:
UFUNCTION()
void Initialize(void);
// Other things
}
Object.cpp
// Other things
void AObject::Initialize()
{
// Does nothing for the moment
}
Creator.cpp
#include "Object.h"
// Other things
void UCreator::BeginPlay()
{
// Get ToSpawn, spawnLocation, rotator, spawnParams - these are all ok.
AActor* Obj = World->SpawnActor<AActor>(ToSpawn, spawnLocation, rotator,
spawnParams);
if(Obj)
{
Obj->Initialize(); // This fails
}
}
Basically when I try to access Initialize from the pointer to Obj, it doesn’t recognise the function. I feel like, from the error I’m getting, that the pointer doesn’t point to the actual instance of the class…
Thanks for the help.