PyObject *py_ue_controller_posses(ue_PyUObject * self, PyObject * args) {

	ue_py_check(self);

	PyObject *obj;
	if (!PyArg_ParseTuple(args, "O:posses", &obj)) {
		return NULL;
	}

	if (!self->ue_object->IsA<AController>()) {
		return PyErr_Format(PyExc_Exception, "uobject is not an APawn");
	}

	if (!ue_is_pyuobject(obj)) {
		return PyErr_Format(PyExc_Exception, "argument is not a UObject");
	}

	ue_PyUObject *py_obj = (ue_PyUObject *)obj;

	if (!py_obj->ue_object->IsA<APawn>()) {
		return PyErr_Format(PyExc_Exception, "argument is not a APAwn");
	}

	APawn *pawn = (APawn *)py_obj->ue_object;
	AController *controller = (AController *)self->ue_object;

	controller->Possess(pawn);

	Py_INCREF(Py_None);
	return Py_None;
}
void AAlessandroMalusaPawn::SpawnDefaultController()
{

	if (AIControllerClass != nullptr && AIControllerClass == AShipAIController::StaticClass())
	{
		FActorSpawnParameters SpawnInfo;
		SpawnInfo.Instigator = Instigator;
		SpawnInfo.bNoCollisionFail = true;
		SpawnInfo.OverrideLevel = GetLevel();

		AController * NewController = GetWorld()->SpawnActor<AShipAIController>(AIControllerClass, GetActorLocation(), GetActorRotation(), SpawnInfo);
	
		if (NewController != nullptr)
		{
			// if successful will result in setting this->Controller 
			// as part of possession mechanics
			NewController->Possess(this);
		}
	}
}
void APawn::SpawnDefaultController()
{
	if ( Controller != NULL || GetNetMode() == NM_Client)
	{
		return;
	}
	if ( AIControllerClass != NULL )
	{
		FActorSpawnParameters SpawnInfo;
		SpawnInfo.Instigator = Instigator;
		SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
		SpawnInfo.OverrideLevel = GetLevel();
		SpawnInfo.ObjectFlags |= RF_Transient;	// We never want to save AI controllers into a map
		AController* NewController = GetWorld()->SpawnActor<AController>(AIControllerClass, GetActorLocation(), GetActorRotation(), SpawnInfo);
		if (NewController != NULL)
		{
			// if successful will result in setting this->Controller 
			// as part of possession mechanics
			NewController->Possess(this);
		}
	}
}