Please not that this bug occurs even when Stop has not been called. You can connect the sequencer player Play function directly to the Event BeginPlay and see this behavior. Note that it is important to have some kind of animation playing to see this behavior. With only an Event Track the problem is harder to reproduce.
I’ve debugged this issue a little bit and the problem seems to be in the following code
void UMovieSceneEventSection::TriggerEvents(TArray<UObject*> EventContextObjects, float Position, float LastPosition)
{
const TArray<FNameCurveKey>& Keys = Events.GetKeys();
if (Position >= LastPosition)
{
for (const auto& Key : Keys)
{
if ((Key.Time >= LastPosition) && (Key.Time <= Position))
{
TriggerEvent(Key.Value, EventContextObjects);
}
}
}
else
{
for (int32 KeyIndex = Keys.Num() - 1; KeyIndex >= 0; --KeyIndex)
{
const auto& Key = Keys[KeyIndex];
if ((Key.Time >= Position) && (Key.Time <= LastPosition))
{
TriggerEvent(Key.Value, EventContextObjects);
}
}
}
}
The first if statement (Position >= LastPosition) is used for forward play and the else part of that if is for backwards play.
What I see happen in the debugger when playing in the forward direction, is that the if
((Key.Time >= LastPosition) && (Key.Time <= Position))
statement evaluates true for two different Position and LastPosition values. The Key.Time value is 1.0.
First it triggers at
Position=1.00000000, LastPosition=0.966666698
and then it trigger again at
Position=1.40000010, LastPosition=1.00000000
Seems to me with this logic there is always a possibility of the event firing twice.