When spawning a pawn that has a PawnMovementComponent attached and destroying the pawn, if a pawn with the same name is re-created it will be missing the PawnMovementComponent.
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "OurPawn") class UMyPawnMovementComponent* MyPawnMovementComponent;
// Initialized in AOurPawn constructor: MyPawnMovementComponent = CreateDefaultSubobject<UMyPawnMovementComponent>(TEXT("MyPawnMovementComponent"));
void SpawnDummy(); void RemoveDummy(); AMyPawn* TempActor;
InputComponent->BindAction("Spawning", IE_Pressed, this, &AMyProject7Character::SpawnDummy); InputComponent->BindAction("Removing", IE_Pressed, this, &AMyProject7Character::RemoveDummy);
void AMyProject7Character::SpawnDummy() { FActorSpawnParameters SpawnParams; SpawnParams.Name = "Pawn123"; SpawnParams.Owner = this; FVector SpawnLocation; FRotator SpawnRotation; SpawnLocation.X = GetActorLocation().X; SpawnLocation.Y = GetActorLocation().Y; SpawnLocation.Z = GetActorLocation().Z; SpawnRotation.Pitch = GetActorRotation().Pitch; SpawnRotation.Roll = GetActorRotation().Roll; SpawnRotation.Yaw = GetActorRotation().Yaw; TempActor = GetWorld()->SpawnActor<AMyPawn>(AMyPawn::StaticClass(), SpawnLocation, SpawnRotation, SpawnParams); } void AMyProject7Character::RemoveDummy() { TempActor->Destroy(); }
pressing Shift+F1 and selecting MyPawn in the world outliner will show the movement component in the details window
Result:
When Spawning is called the second time, the pawn is created but is missing the PawnMovementComponent
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-23291 in the post.
0 |
Component | UE - Foundation - Core |
---|---|
Affects Versions | 4.9.2, 4.10 |
Target Fix | 4.17 |
Created | Nov 12, 2015 |
---|---|
Resolved | Jul 10, 2017 |
Updated | Aug 10, 2017 |