Announcement

Collapse
No announcement yet.

Blueprint latent actions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Blueprint latent actions

    I've got a situation where I want to tell my character to do something in the level blueprint graph, and have it tell me when it either succeeds or fails so I can do something else after. In UE3 I'd just make a latent kismet action with two output pins and fire off the relevant one at the right time, but I can't figure out how to do the same thing in UE4.

    I've looked at the latent action stuff that nodes like Delay use, but that looks like it can only have one output pin. I've also had a look at the AI MoveTo node (which actually has the pins I want on it), but the copy I made of it wouldn't compile because it extends from K2Node which has 'minimalAPI' on it, and I've never figured out how to extend classes with that on them (is there a way?).

    Does anyone know how to do what I'm after?

    #2
    As long as you have BlueprintGraph in your PublicDependencyModuleNames in your Module.Build.cs file you should be able to compile and link when extending from K2Node.

    As you noted there isn't currently a way to have multiple possible outputs on a latent function that is just generated via a UFUNCTION, so creating a custom node is likely what you will need to do.

    Comment


      #3
      Thanks, that's looking like it'll work now.

      I do have another problem though. I added BlueprintGraph to the PublicDependencyModuleNames, but when I ran 'Generate Visual Studio project files', I got the following error:
      Running C:/UE4/Unreal Engine/4.4/Engine/Binaries/DotNET/UnrealBuildTool.exe -projectfiles -project="C:/.../MyGame.uproject" -game -rocket -progress
      Discovering modules, targets and source code for game...
      ERROR: Exception thrown while processing dependent modules of MyGame
      Exception thrown while processing dependent modules of BlueprintGraph
      Exception thrown while processing dependent modules of KismetCompiler
      Exception thrown while processing dependent modules of UnrealEd
      Exception thrown while processing dependent modules of AnimGraph
      Exception thrown while processing dependent modules of GraphEditor
      Exception thrown while processing dependent modules of KismetWidgets
      Exception thrown while processing dependent modules of ContentBrowser
      Exception thrown while processing dependent modules of SourceControlWindows
      Exception thrown while processing dependent modules of AssetTools
      Exception thrown while processing dependent modules of TextureEditor
      Exception thrown while processing dependent modules of MainFrame
      Exception thrown while processing dependent modules of LevelEditor
      Exception thrown while processing dependent modules of WorldBrowser
      Exception thrown while processing dependent modules of MeshUtilities
      ERROR: Couldn't find module rules file for module 'nvTriStrip'.

      Any ideas? I'm on unmodified 4.4.0 at the moment. I can remove BlueprintGraph temporarily while I generate the files, it's just a bit of a faff.

      Comment


        #4
        Have a look at how UK2Node_LatentOnlineCall and OnlineBlueprintCallProxyBase works. It's probably a bit nicer of a building block than a raw UK2Node_BaseAsyncTask. Despite the name, it doesn't actually have any online specific code in it, but it's what we use for things like async leaderboard or achievement writes.

        RE: your linking error, it sounds like it's an issue with using nvTriStrip, but I'm not sure why that would cascade in such a way. The OnlineBlueprintSupport module adds BlueprintGraph to it's PrivateDependencyModuleNames, not PublicDependencyModuleNames, maybe try that?

        Cheers,
        Michael Noland

        Comment


          #5
          I'll have a look at those too, thanks. I've got the other one working now, but it's always useful to find other ways of doing things.

          Adding it to the private ones didn't help, unfortunately. Neither did getting 4.4.3. I also just tried starting a new project and adding it to the PrivateDependencyModuleNames of that one and the same thing happened.

          Comment


            #6
            One thing to make sure of:

            Do you have a separate module for your editor-only classes? Things like BlueprintGraph are editor-only modules that shouldn't be linked into a monolithic game. I'd expect that to only cause a problem when compiling Development (as opposed to Development Editor, etc...), but maybe it affects project file generation as well.

            Cheers,
            Michael Noland

            Comment


              #7
              Not at the moment, no. I did wonder if I'd need one of those but it managed to compile fine without it. Though, like you say, I've only been running Development Editor so far. How do I go about making one? I had a look through some of the example projects I've downloaded but none of them had an editor module.

              Comment


                #8
                Create a new module (folder + Build.cs file) and add it to the .uproject. In your .uproject, you can control both the loading point and 'type' of a module, e.g.,:
                {
                "Name": "FortniteEditor",
                "Type": "Developer",
                "LoadingPhase": "Default"
                }

                Developer means it loads in WITH_EDITOR builds (e.g., -game builds), not just when actually running the editor, and the loading phase controls when it gets loaded. For anything related to Blueprint or Anim BP nodes, you'll want Developer as opposed to Editor, since we still compile-on-run in -game.

                The Editor type is only for actual interactive GUI stuff that is only shown when running the editor (which could also live in a Developer module).

                Cheers,
                Michael Noland
                Last edited by Michael Noland; 09-17-2014, 05:30 PM.

                Comment


                  #9
                  I've managed to make an editor module of some sort, but I'm still having trouble so could you check I've put it together the right way please?

                  I've now got a MyGameEditor folder with Classes/Public/Private folders inside and a PACGameEditor.Build.cs file that has MyGame and BlueprintGraph added to PrivateDependencyModuleNames. I changed MyGame.Target.cs to include MyGameEditor if UEBuildConfiguration.bBuildEditor is true, and MyGameEditor.Target.cs has MyGame and MyGameEditor added always. I didn't change MyGame.uproject at all, but it generates the VS project fine now anyway.

                  I've also got MyGameEditor.h in the Classes folder which includes MyGameClasses.h as well as MyGameEditorClasses.h. And I moved over the blueprint node I'd made but not anything else. I've got a MyGameEditor.cpp file but that has nothing in it. Is that all right?

                  The problem I've got now is it won't compile like this (Development Editor, that is. Development is fine). My blueprint node has the following in it:
                  Code:
                  #include "MyGameEditor.h"
                  
                  UK2Node_MyGameNode::UK2Node_MyGameNode(const class FPostConstructInitializeProperties& PCIP)
                  : Super(PCIP)
                  {
                  	ProxyFactoryFunctionName = GET_FUNCTION_NAME_CHECKED(UMyBlueprintHelperLibrary, CreateProxyObject);
                  	ProxyFactoryClass = UMyBlueprintHelperLibrary::StaticClass();
                  	ProxyClass = UMyAsyncTaskBlueprintProxy::StaticClass();
                  }
                  And I'm getting an unresolved external symbol error for UMyBlueprintHelperLibrary::GetPrivateStaticClass and UMyAsyncTaskBlueprintProxy::GetPrivateStaticClass. I even tried including the relevant header files directly but that didn't help. Any ideas? Do the blueprint helper library and the async task proxy need to go in the editor module as well? I thought maybe not since they have gameplay stuff in them.

                  Comment


                    #10
                    Hi Stormharrier,

                    You need to 'export' the UMyBlueprintHelper library using a macro named your game name, so it should like like this in MyBlueprintHelper.h:

                    UCLASS(stuff)
                    class MYGAME_API UMyBlueprintHelper : public UBlueprintLibrary
                    {
                    ...
                    }

                    You can export the whole class using MODULENAME_API like I showed above, or choose to only export specific methods by using that macro on individual functions (but you also want to use MinimalAPI inside of UCLASS() if you do this, so that methods like GetClass()/etc... that are autogenerated get exported).

                    Cheers,
                    Michael Noland

                    Comment


                      #11
                      That works, after a bit more tweaking. Thanks for all the help

                      Comment

                      Working...
                      X