C++ Usage Kismet Array Library

Short answer: Maybe I should have used stronger language: You can’t.

But that’s not entirely true either, there’s probably some way to do it. It just isn’t worth the effort over calling the actual member functions.

I’m not sure what you mean by advantages. All of those things are either done Blueprint side, so calling them from native won’t have the same benefits (ie avoiding additional checks) or are more clearly expressed using the actual member functions.

The only reason the Kismet functions exist is to deal with the template nature of the TArray. But in native, the C++ compiler already does that.

There are versions of insert and add that you can call to add uninitialized instances to an array if that’s what you really need. However it would be more correct to just construct the instance of the structure that you need and add it to the array. You could do this with a temporary on the stack (which the compiler would probably optimize away, or you could directly construct it in the array using the Emplace function (although I think that’s limited to adding to the end of the array).

Any suspicions about advantages are largely outweighed by the fact that those functions aren’t designed to be called directly in native. They’re designed to be called from the Blueprint VM.

While I wouldn’t discourage anyone from using Blueprint functions to understand how to do something in native, it’s not always a good idea to just write C++ as a bunch of calls to the same functions called by Blueprint. Almost always there is a better version that should be used instead that is more efficient, more readable or more powerful/flexible. If you’re going to write C++ it’s worth the effort to write actual C++ and not just a faux-Blueprint in C++.

2 Likes