Button toggle instead of held for grabbing objects

How would you go about making the Grab function a button toggle instead of one where you have to hold down the button? I tried all the EInputEvents and none of them worked. I found the InputKey from the APlayerController class which returns a bool but I don’t know how I would define an FKey.

Example code of what I want to do:

bool KeyDown = APlayerController::InputKey(FKey "F")
		if(KeyDown)
		{
			UE_LOG(LogTemp, Warning, TEXT("F key pressed!"));
		}
2 Likes

Create a bool member in the grabber e.g.bool bIsHoldingObject and then use that in the Grab function and invert it whenever an object is held or released.

You shouldn’t need the Release function with this change so I would suggest you rename Grab to ToggleGrab or something and remove Release and it’s mappings.

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

Privacy & Terms