我想要的行为是游戏手柄左摇杆 2d 向量将在其最新位置的每个刻度处发送输入,无论它是四处移动还是已返回到 0。
EnhancedInputComponent->BindAction(AimAction, ETriggerEvent::Started ...
时,每次摇杆移动超过驱动阈值时,我都会收到 1 个事件 - 不太酷,因为当摇杆位置发生变化或返回到 0 时,我不会收到更多事件EnhancedInputComponent->BindAction(AimAction, ETriggerEvent::Ongoing ...
时,我根本没有收到任何事件。#pragma once
#include "InputTriggers.h"
#include "UInputTriggerChordTicking.generated.h"
UCLASS()
class UInputTriggerChordTicking : public UInputTriggerChordAction
{
GENERATED_BODY()
public:
UInputTriggerChordTicking();
};
#include "Input/UInputTriggerChordTicking.h"
UInputTriggerChordTicking::UInputTriggerChordTicking()
{
bShouldAlwaysTick = true;
}
#pragma once
#include "InputModifiers.h"
#include "UInputModifierAccumulating.generated.h"
UCLASS()
class UInputModifierAccumulating : public UInputModifier
{
GENERATED_BODY()
public:
virtual FInputActionValue ModifyRaw_Implementation(const UEnhancedPlayerInput* PlayerInput, FInputActionValue CurrentValue, float DeltaTime) override;
protected:
float AccumulatedValue = 0;
};
#include "Input/UInputModifierAccumulating.h"
FInputActionValue UInputModifierAccumulating::ModifyRaw_Implementation(const UEnhancedPlayerInput* PlayerInput, FInputActionValue CurrentValue, float DeltaTime)
{
const float CurrentFloat = CurrentValue.Get<float>();
AccumulatedValue += CurrentFloat;
return FInputActionValue(AccumulatedValue);
}