Hi,
I haven’t found anyone with this issue (usually peoples try to setup a double clic, not to get rid of it ), and I’ve explored all GPT solutions.
I have only one input action, and I want to use it on triggered. While I press the input, there is a function executing on tick, and when I release it just executes an other function. So far it is very simple and my code works, exept after the first release I have to double click and maintain the second click to trigger the input whereas release works normally.
Here is the action asset :
And the mapping context :
The game is very simple I have one main mechanic, no pawn or character so everything takes place in the controller. I don’t plan to use BP nodes so I haven’t set any UPROPERTY or UFUNCTION
.h :
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "InputActionValue.h"
#include "BallPlayerController.generated.h"
/**
*
*/
UCLASS()
class OPERATIONBALL_API ABallPlayerController : public APlayerController
{
GENERATED_BODY()
public:
ABallPlayerController();
//-----------------------------------Functions----------------------------------------
void BeginGame_Controller(); //Called when level is ready
void AddOrRemoveInput(bool Add);
protected:
virtual void BeginPlay() override;
//-----------------------------------Inputs-------------------------------------------
class UInputAction* TouchAction = nullptr;
void TouchEvent(const FInputActionValue& Value);
void ReleaseTouchEvent(const FInputActionValue& Value);
};
In the .cpp I have these includes :
#include "OperationBall/GameObjects/BallPlayerController.h"
#include "Kismet/GameplayStatics.h"
#include "Camera/CameraActor.h"
#include "InputMappingContext.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
My function called when level is ready (I have a widget doing a fade out from black, it is ready when the fade is over) :
void ABallPlayerController::BeginGame_Controller()
{
FInputModeGameAndUI inputMode;
bShowMouseCursor = true;
ABallPlayerController::AddOrRemoveInput(true);
}
The function to add mapping context. I’ve already logged everything here, the components, the subsytem, everything is fine so I’ve removed a bunch of if/else/log :
void ABallPlayerController::AddOrRemoveInput(bool Add)
{
UInputMappingContext* InputMapping = LoadObject<UInputMappingContext>(nullptr, TEXT("/Game/Input/IMC_InGame"));
if (InputMapping)
{
UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(this->GetLocalPlayer());
if (Add)
{
UE_LOG(LogTemp, Warning, TEXT("Add Mapping Context"));
Subsystem->AddMappingContext(InputMapping, 0);
UInputComponent* InputComp = this->InputComponent;
UEnhancedInputComponent* EnhancedInputComp = CastChecked<UEnhancedInputComponent>(InputComponent);
EnhancedInputComp->BindAction(TouchAction, ETriggerEvent::Triggered, this, &ABallPlayerController::TouchEvent);
EnhancedInputComp->BindAction(TouchAction, ETriggerEvent::Completed, this, &ABallPlayerController::ReleaseTouchEvent);
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Remove Mapping Context"));
Subsystem->RemoveMappingContext(InputMapping);
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("Controller didn't found input mapping in Game/Input"));
}
}
And the triggered functions :
void ABallPlayerController::TouchEvent(const FInputActionValue& Value)
{
UE_LOG(LogTemp, Warning, TEXT("TOUCH"));
}
void ABallPlayerController::ReleaseTouchEvent(const FInputActionValue& Value)
{
UE_LOG(LogTemp, Warning, TEXT("RELEASE"));
}
AddOrRemoveInput isn’t used with “false” for the moment so I know from the log that the mapping context isn’t removed (and if so, I shouldn’t be able to double click).
This input is the only one I use so I don’t think it could be consumed elsewhere.
Maybe my fade widget? It is removed from parent when the fade is over anyway.
Tell me if I ommit any info/ clue, I’ve tried to review all potential culprits but sometimes it is not enough
Thanks !
Edit : I’m looking for this setup :