Hi. I’m trying to create AnimNotifies in code so I can drive notifies from a excel datatable. The code below seems to work, it adds a notify to notify track 0 in my UAnimMontage is visible in the editor and fires events in game. However if I click the notify the editor crashes immediately.
I can see in the call stack that it’s an index out of range error but I’m not sure where it’s coming from. Given that it crashes when I click on it, is there something I need to set for the notifies property editor not to throw a fit?
Any ideas? This has me stumped. I’m not a very seasoned coder so baby steps are appreciated.
Thanks in advance.
Code:
montage->Notifies.Empty();
// Insert a new notify record and spawn the new notify object
int32 NewNotifyIndex = montage->Notifies.Add(FAnimNotifyEvent());
FAnimNotifyEvent& NewEvent = montage->Notifies[NewNotifyIndex];
NewEvent.NotifyName = FName("Combo");
class UObject* AnimNotifyClass = ConstructObject<UObject>(UAnimNotifyState::StaticClass());
NewEvent.NotifyStateClass = Cast<UAnimNotifyState>(AnimNotifyClass);
// Set default duration to 1 frame for AnimNotifyState.
if (NewEvent.NotifyStateClass)
{
NewEvent.NotifyName = FName(*NewEvent.NotifyStateClass->GetNotifyName());
NewEvent.SetDuration(1 / 30.f);
NewEvent.EndLink.Link(montage, NewEvent.EndLink.GetTime());
}
else
{
NewEvent.NotifyName = FName(*NewEvent.Notify->GetNotifyName());
}
montage->MarkPackageDirty();
Call Stack:
Unknown exception - code 00000001 (first/second chance not available)
Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.6\Engine\Source\Runtime\Core\Public\Containers\Array.h] [Line: 679]
Array index out of bounds: -1 from an array of size 1
KERNELBASE + 293772 bytes
UE4Editor_Core + 3092333 bytes
UE4Editor_Core + 1597672 bytes
UE4Editor_Core + 1479042 bytes
UE4Editor_Persona + 685626 bytes
UE4Editor_Persona + 669553 bytes
UE4Editor_PropertyEditor + 2498525 bytes
UE4Editor_PropertyEditor + 2763666 bytes
UE4Editor_PropertyEditor + 2435518 bytes
UE4Editor_PropertyEditor + 2657981 bytes
UE4Editor_PropertyEditor + 2659926 bytes
UE4Editor_Kismet + 3608592 bytes
UE4Editor_Kismet + 3823122 bytes
UE4Editor_Kismet + 3803976 bytes
UE4Editor_Kismet + 1037444 bytes
UE4Editor_Persona + 2113709 bytes
UE4Editor_Persona + 3134492 bytes
UE4Editor_Persona + 3156828 bytes
UE4Editor_Persona + 2124127 bytes
UE4Editor_Persona + 1838417 bytes
UE4Editor_Persona + 1853142 bytes
UE4Editor_Persona + 2169587 bytes
UE4Editor_Persona + 2086953 bytes
UE4Editor_Slate + 427589 bytes
UE4Editor_Slate + 156365 bytes
UE4Editor_Slate + 832709 bytes
UE4Editor_Slate + 770598 bytes
UE4Editor_Core + 2484697 bytes
UE4Editor_Core + 2400747 bytes
UE4Editor_Core + 2489259 bytes
UE4Editor_Core + 2387170 bytes
user32 + 5054 bytes
user32 + 4567 bytes
UE4Editor_Core + 2490470 bytes
UE4Editor!FEngineLoop::Tick() + 3434 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\launchengineloop.cpp:2193]
UE4Editor!GuardedMain() + 479 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\launch.cpp:131]
UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.6\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]