Hello,
When using the following function to set the position of an anim single node instance manually
if (UAnimSingleNodeInstance* Instance = Mesh->GetSingleNodeInstance()) { Instance->SetPosition(Position, bFireNotifies); }
I noticed that the audio notify located on the anim sequence base wasn’t being activated and that only the notifications present on the UAnimMontage asset were being used. I tested this with various notifies in the anim sequence asset and confirmed none triggered whilst the montage ones did.
on further investigation, i saw that the call in
UAnimSingleNodeInstance::SetPositionWithPreviousTime
for getting the notification contexts goes to the anim sequence base one only as it is not overwrittein for anim montages
UAnimSequenceBase * SequenceBase = Cast<UAnimSequenceBase> (CurrentAsset); if (SequenceBase) { SequenceBase->GetAnimNotifiesFromDeltaPositions(InPreviousTime, Proxy.GetCurrentTime(), NotifyContext); }
However, when you look at the animcomposite class which inherits from the same AnimCompositeBase class as UAnimMontage does. You can see that it accounts for this when getting the anim notifies for the composite
void UAnimComposite::GetAnimNotifiesFromDeltaPositions(const float& PreviousPosition, const float & CurrentPosition, FAnimNotifyContext& NotifyContext) const { Super::GetAnimNotifiesFromDeltaPositions(PreviousPosition, CurrentPosition, NotifyContext); AnimationTrack.GetAnimNotifiesFromTrackPositions(PreviousPosition, CurrentPosition, NotifyContext); }
Is this expected behaviour in the UAnimMontage asset?
locally i have changed the code to override the function in the UAnimMontage with the following
`void UAnimMontage::GetAnimNotifiesFromDeltaPositions(const float& PreviousPosition, const float& CurrentPosition, FAnimNotifyContext& NotifyContext) const
{
// Get notifies from the montage tracks
Super::GetAnimNotifiesFromDeltaPositions(PreviousPosition, CurrentPosition, NotifyContext);
// Now we have the notifications from the anim montage tracks we also need to supply the notifies from the anim sequences being referenced
for (const FSlotAnimationTrack& SlotTrack : SlotAnimTracks)
{
// Check all anim track segments as if the positions are out of the range of the segment, then it will return early – saves checking twice
// Checking all segments instead of just the active one means we can catch any notifies we might skip over if the two positions start and end on two different animations
for (const FAnimSegment& Segment : SlotTrack.AnimTrack.AnimSegments)
{
SlotTrack.AnimTrack.GetAnimNotifiesFromTrackPositions(PreviousPosition, CurrentPosition, NotifyContext);
}
}
}`
and this seems to work.
i was just wondering if this could / should be integrated at the engine level rather than just a local change?