UE4- Note - Examples of common logic functions to achieve

Some examples of common features in mind their implementation.

 

Q. Double-analog (applied to double jump / double-click, etc. buildup W):

Recommended implemented in C ++, BP well positioned to maintain search = _ =

BP:

Macro to:

 

C ++ implementation:

---------- split split split -----------

.h file:

UENUM(BlueprintType)
enum class EM_ClickType : uint8
{
    EM_FisrtClick    UMETA(DisplayName = "FisrtClick"),
    EM_DoubleClick    UMETA(DisplayName = "DoubleClick")
};

UCLASS()
class UBPLibrary_CommonDemonstrate : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()
public:
    UFUNCTION(BlueprintCallable, meta = (DeterminesOutputType = "actorClass"))
        static EM_ClickType DoubleClick();
};

 

cpp file:

EM_ClickType UCppBPLibrary_CommonDemonstrate::DoubleClick()
{
    static bool bReadyOnce = false;
    if (bReadyOnce)
    {
        bReadyOnce = false;
        return  EM_ClickType::EM_DoubleClick;// double click
    }
    else
    {
        bReadyOnce = true;
        TFuture<void> future = Async<void>(EAsyncExecution::TaskGraph, [=]
        {
            FPlatformProcess::Sleep(0.25);
            if (bReadyOnce)
            {
                bReadyOnce = false;
                return;
            }
        });

        return  EM_ClickType::EM_FisrtClick; // first click
    }
}

 

use:

 

Guess you like

Origin www.cnblogs.com/linqing/p/11226415.html