Hi
I have a player that i want to spawn a device then possess it. I’m currently spawning the device and then UnPossess the player and Possess the device, however when I try possesing the device it throws an exception error:
Exception thrown at 0x00007FF9FA5DDAFA (UE4Editor - Engine.dll) in UE4Editor.exe: 0xC0000005 : Access violation reading location 0x0000000000000000.
Both player and device is using the same controller
My code is:
if (Drone)
{
UWorld* world = GetWorld();
if (world)
{
FActorSpawnParameters spawnParams;
spawnParams.Owner = this;
FVector SpawnLocation = DeviceSpawnPoint->GetComponentLocation();
FRotator SpawnRotation = DeviceSpawnPoint->GetComponentRotation();
world->SpawnActor<ACharacter>(Device, SpawnLocation, SpawnRotation, spawnParams);
AController* SavedController = GetController();
SavedController->UnPossess();
SavedController->Possess(Cast<ACharacter>(Device));
}
}
Thank you