Fix name reuse issues for actors, and make luprex IDs more readable

This commit is contained in:
2025-08-04 17:13:34 -04:00
parent 13f8d2669c
commit 9b304985e3
6 changed files with 46 additions and 39 deletions

View File

@@ -38,6 +38,8 @@ void UlxTangible::DeleteCurrentActor()
// Now destroy the actor itself. According to various
// documents I've read online, it may be necessary to take
// further steps to delete the object. Not clear.
UE_LOG(LogLuprexIntegration, Display, TEXT("Deleting actor: %s"), *CurrentActor->GetName());
CurrentActor->Rename(nullptr);
CurrentActor->Destroy();
// If this actor previously was posessed by a player controller,
@@ -75,7 +77,7 @@ void UlxTangible::SetActorBlueprint(const FString &XName) {
FActorSpawnParameters params;
// Give the new actor a reasonable name.
params.Name = FName(*FString::Printf(TEXT("%s_%ld"), *Name, TangibleId));
params.Name = FName(*FString::Printf(TEXT("Tan:%s_%ld"), *Name, TangibleId));
// Currently, the actor is spawned at (0,0,0), which is not good.
// We should spawn at the actor's current location. I'll get to it
@@ -91,6 +93,8 @@ void UlxTangible::SetActorBlueprint(const FString &XName) {
// want to delay that until after we've had a chance to set
// up the TangibleComponent.
params.bDeferConstruction = true;
params.bNoFail = true;
UE_LOG(LogLuprexIntegration, Display, TEXT("Creating Actor: %s"), *params.Name.ToString());
AActor* a = w->SpawnActor(blueprint, &transform, params);
check(a != nullptr);