Description

Regression No, according to affects versions 4.27 and 4.27.1

The restore process proceeds in the following order :
1. Remove spawnable actor in first cut (no effect because the actor is already removed )
2. Restore location of possessable actor
3. Remove spawnable actor in second cut (detaching from parent)
So after restoring the position, it will be further changed by detaching.

Destroying all spawnable actors before restoring possessable actor's location work around this issue.

The following code is a work around (but ugly).

void FPreAnimatedStateExtension::RestoreGlobalState(const FRestoreStateParams& Params)
{
...
	// workaround begins : First, restore the states stored in FAnimTypePreAnimatedStateObjectStorage. (This will delete the spawned objects)
	for (int32 Index = 0; Index < GroupMetaData.GetMaxIndex(); ++Index)
	{
		if (!GroupMetaData.IsAllocated(Index))
		{
			continue;
		}

		FPreAnimatedGroupMetaData& Group = GroupMetaData[Index];

		for (int32 AggregateIndex = Group.AggregateMetaData.Num() - 1; AggregateIndex >= 0; --AggregateIndex)
		{
			FAggregatePreAnimatedStateMetaData& Aggregate = Group.AggregateMetaData[AggregateIndex];
			if (Aggregate.NumContributors == 0 && (!Aggregate.TerminalInstanceHandle.IsValid() || Aggregate.TerminalInstanceHandle == Params.TerminalInstanceHandle))
			{
				if(Aggregate.ValueHandle.TypeID.TypeID== FAnimTypePreAnimatedStateObjectStorage::StorageID.TypeID )
				{
					TSharedPtr<IPreAnimatedStorage> Storage = GetStorageChecked(Aggregate.ValueHandle.TypeID);
					Storage->RestorePreAnimatedStateStorage(Aggregate.ValueHandle.StorageIndex, EPreAnimatedStorageRequirement::Persistent, EPreAnimatedStorageRequirement::None, Params);

					Group.AggregateMetaData.RemoveAt(AggregateIndex, 1, false);
				}
			}

			if (Group.AggregateMetaData.Num() == 0)
			{
				// Remove at will not re-allocate the array or shuffle items within the sparse array, so this is safe
				Group.GroupManagerPtr->OnGroupDestroyed(Index);
				GroupMetaData.RemoveAt(Index);
			}
		}
	}
	// workaround ends

	// Ensure that the entries are restored in strictly the reverse order they were cached in
	for (int32 Index = 0; Index < GroupMetaData.GetMaxIndex(); ++Index)
	{
		if (!GroupMetaData.IsAllocated(Index))
		{
			continue;
		}

		FPreAnimatedGroupMetaData& Group = GroupMetaData[Index];
...
}

Steps to Reproduce
  1. Open attached project on UE4.27 [Link Removed]
  2. Run PIE
  3. Press home key to start playing level sequence (RestoreState of LevelSequenceActor in the level has a check. )

Result

The location of the ThirdPersonCharacter will be restored to a non-original point.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-134758 in the post.

0
Login to Vote

Fixed
ComponentUE - Anim - Sequencer
Affects Versions4.274.27.1
Target Fix5.0
Fix Commit19118130
Main Commit19161693
Release Commit19118130
CreatedNov 12, 2021
ResolvedFeb 24, 2022
UpdatedJan 26, 2023