Mathis_2
(MathisBessa)
1
Hi guys !
I’m doing an item pick up system and I was using the Bluprint event system.
Right now I’m doing everything through script except this : EditorKeyPressed(FKey Key, EInputEvent Event)
this works well … During the editor. But when I play obviously it doesn’t work.
So I want to know if there’s something equal for ingame event.
My actor inherit from AActor.
1 Like
Chris528
(Chris528)
2
Try using WasInputKeyJustPressed, which is a function in the APlayerController class.
if (yourPlayerController->WasInputKeyJustPressed(EKeys::B))
{
// do something
}
1 Like
Mathis_2
(MathisBessa)
3
Hi Chris, Thank you for your quick answer.
This is not what i’m trying to do.
Basically I used this with Blueprint and what I want to do is implement the “OnKeyPressed” in my current Actor.
This way after the
ReceiveActorBeginOverlap(class AActor* Other)
I enable the EnableInput(MyPC);
And then I want to do the same thing as I do with Blueprint : KeyEvent : E but through script
Mathis_2
(MathisBessa)
4
Alright guys I found a way to do it :
I enable the Tick function :
Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (!bCanTick)
return;
if (currentPlayerController != NULL)
{
if (currentPlayerController->WasInputKeyJustPressed(EKeys::E))
{
PickupOnUse();
}
}
}
the boolean bCanTick is set to true when the player begin overlap and false when it ends.
2 Likes