IE_Pressed not triggering message, Building Escape

IE_Released is properly triggered, but IE_Pressed is not.
Pertinent code below:

Grabber.cpp:

#include "DrawDebugHelpers.h"
#include "Engine/World.h"
#include "GameFramework/PlayerController.h"
#include "GameFramework/Pawn.h"
#include "Grabber.h"

void UGrabber::BeginPlay()
{
	Super::BeginPlay();

	InputComponent = GetOwner()->FindComponentByClass<UInputComponent>();
	if (InputComponent)
	{
		InputComponent->BindAction("Grab", IE_Pressed, this, &UGrabber::GrabM);
		InputComponent->BindAction("Grab", IE_Released, this, &UGrabber::ReleaseM);
	}
}

void UGrabber::GrabM()
{
	if (IE_Pressed)
	{
		UE_LOG(LogTemp, Warning, TEXT("Grabber Pressed"));
	}
}

void UGrabber::ReleaseM()
{
	if (IE_Released)
	{
		UE_LOG(LogTemp, Warning, TEXT("Grabber Released"));
	}
}

Grabber.h:

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PhysicsEngine/PhysicsHandleComponent.h"
#include "Grabber.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UGrabber : public UActorComponent
{
	GENERATED_BODY()

private:
	UInputComponent* InputComponent = nullptr;

	void GrabM();

	void ReleaseM();
};

Again, “Grabber Released” triggers correctly,
“Grabber Pressed” has never triggered.

I have tried changing game modes from Game Only, to Game and UI.
Also, changing Mouse Capture settings to any available.
I have saved everything, restarted, refreshed, recompiled.

This is one of those things that i think should be working fine, so i have no further ideas.
Thank you

p.s. the Pawn include was just from a test

Bah.
I took the If statement out, and now it is working.

went from:

void UGrabber::GrabM()
{
	if (IE_Pressed)
	{
		UE_LOG(LogTemp, Warning, TEXT("Grabber Pressed"));
	}
}

to just:

void UGrabber::GrabM()
{
	UE_LOG(LogTemp, Warning, TEXT("Grabber Pressed"));
}

Strange to me that the Released works in the If statement, but not the Pressed.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms