x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Create AnimNotify in c++

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]


 

 
Product Version: Not Selected
Tags:
more ▼

asked Dec 10 '14 at 08:37 PM in C++ Programming

avatar image

Hum
56 8 15 15

avatar image Nonlin Oct 15 '17 at 05:08 AM

Where do you put your code?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Neglected to link the new notify to the montage. Silly mistake. The line below fixed it.

NewEvent.Link(montage, 0.05f);

more ▼

answered Dec 10 '14 at 11:44 PM

avatar image

Hum
56 8 15 15

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

NewEvent.NotifyStateClass = Cast(AnimNotifyClass);

That line is wrong as you are casting a UClass to a UAnimNotifyState. What you want is UAnimNotifyState::StaticClass()

more ▼

answered Dec 10 '14 at 09:49 PM

avatar image

joeGraf STAFF
1.5k 35 12 69

avatar image Hum Dec 10 '14 at 10:37 PM

Hi Joe, thanks for getting back to me. I tried UAnimNotifyState::StaticClass() but that returns a UClass so I have to cast to UAnimNotifyState anyway right? Maybe I'm missing something? NewEvent.NotifyStateClass = UAnimNotifyState::StaticClass();

I've set things up the same way as I found in the source code at SAnimNotifyTrack::CreateNewNotifyAtCursor and my code above seems to work fine and fires notify events with my custom notify, it's just when I click on it in persona that things go haywire.
Do I need to register a new notify with persona in any particular way that may cause a crash when I try to view its properties?

Apologies if I'm doing something silly here but the code I have seems to be working for the most part.

avatar image joeGraf STAFF Dec 10 '14 at 10:47 PM

Sorry, the programmer that set that struct up broke convention, so I made a bad assumption. Typically, SomeThingClass means the static class (UClass) of the instance and not an instance.

I just looked at CreateNewNotifyAtCursor() and in that code only one of the things will be true: either it's a state object or a notify object. One of those casts are going to fail.

My guess is that the Notify field is not being zeroed to NULL, where their code is zeroing in both paths. Try zeroing it.

avatar image Hum Dec 10 '14 at 11:43 PM

So it seems I overlooked one little thing. I forgot to link my new notify event to my montage. I added this line just after creating my new event and naming it and everything seems to be working as expected. NewEvent.Link(montage, 0.05f);

Thanks for your help Joe, I hope I didn't waste too much of your time.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question