error Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast

Hi

I am trying to create a bind action by override SetupPlayerInputComponent and call a function for the used key like this

void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);

	//Bind pickup actions
	PlayerInputComponent->BindAction("Pickup", IE_Pressed, this, &AMyPawn::OnPickup);
	
}

Problem in the BindAction I get this error:

note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
C:\Program Files\Epic Games\UE_5.1\Engine\Source\Runtime\Engine\Classes\Components\InputComponent.h(873): note: see declaration of ‘UInputComponent::BindAction’
C:\Unreal\CryptRaider3\Source\CryptRaider\MyPawn.cpp(36): note: while trying to match the argument list ‘(const char [7], EInputEvent, AMyPawn , void (__cdecl AMyPawn:: )(float))’

what this error mean and how to fix it ?

Thanks

make sure OnPickup is void and doesn’t have parameter
and make sure it has UFUNCTION()

1 Like

many thanks

why I can not have parameters I could use something like this

void AMyCharacter::OnJump(UInputAction* Action, ETriggerState TriggerState)
{
    // Check if the action is valid and the trigger state is started
    if (Action && TriggerState == ETriggerState::Started)
    {
        // Call the jump function from the character class
        Jump();
    }
}

So how to check for trigger state ?

The function that will be bound must have the same parameter as the delegate.

PlayerInputComponent->BindAction is legacy input system. While ETriggerState is Enhanced Input System. Also, ETriggerState seems to be an enum for internal use.

U can use this instead
EnhancedInputComponent->BindAction(Jump_Action, ETriggerEvent::Started, this, &AMyCharacter::OnJump
where Jump_Action is UInputAction, u can look at the template project for the example.

1 Like