However, for some reason the controller that gets spawned has the pawn set to NULL. ie. when I call GetPawn() it returns null. I checked to make sure that the controller is getting possessed by it and the function PossessedBy() does in fact fire, but upon closer inspection even there the controller has pawn equal to null. Its weird because the pawn recognizes the controller but the controller doesn’t know the pawn exists. Any help would be appreciated!
Edit: I tried putting it in the comments but it didn’t format right so here is how I spawned my actor:
Not exactly this is how I spawned my actor (though I believe its supposed to call Possess()
this->spawnedUnit = (AUnitPawn*)world->SpawnActor(BPUnitType, &spawnLocation, &spawnRotation, spawnParams);
this->spawnedUnit->team = this->team;
I looked through the log and I couldn’t find anything that mentioned the controller. I think that the controller is in fact spawning though because I can access it. The controller doesn’t return null only the getpawn() function. Also idk if its relevant but when I put in a breakpoint in the function PossessedBy(AController* NewController) in my pawn, Paw, Character, and PlayerState all are null inside of the controller.
So I did some more digging and stepped through the code and I found out where its going wrong. So when NewController->Possess(this); is called it goes through some more checks and eventually end up at OnPossess(InPawn) from here there is a bunch of stuff that I can’t follow as a lot of it simply says file not found. However eventually it ends up in void AController::Possess(APawn* InPawn) This is where the problem is because somewhere between the Possess from AAIController and here the pawn variable disapears. When I looked at the varialbes for “this” pawn could be found in AAIController::Possess but not AController::Possess. Hope this can maybe help figure it out some.
So I finally “fixed” the issue. I still have no clue why it wasn’t working but I created a new class derived from Pawn and then copied the code over from the old one and now it works fine. Not sure what the issue was with the old one (it’s literally the same exact code I basically copy and pasted) but at least its working now.