Using IE_Pressed within an Actor

Hi guys,

When I tried to reimplement the Keypress in the challenge by going through the docs i ended up with

InputComponent->BindAction("GrabberMapping", EInputEvent::IE_Pressed, this, &UGrabber::Grab);

(Note: EInputEvent::IE_Pressed)

This was because the parameter is for const EInputEvent KeyEvent, Enum.

How is Ben able to use the IE_Pressed value directly in the BindAction() method call please?

Also could the same have been done for the collision object query params?:

GetWorld()->LineTraceSingleByObjectType(
    OUT Hit,
    PlayerViewPointPosition,
    LookAtPosition,
    FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody),
    CollisionParams
);

im not sure of the reason, i believe because the parameter is of a specific type you can use the enum value directly (so you can use IE_Pressed instead of EInputEvent::IE_Pressed, same for the ECollisionChannel)

FHitResult UGrabber::GetFirstPhysicsBody()
{
	FHitResult Hit;
	FCollisionQueryParams TraceParams(FName(TEXT("")), false, GetOwner());
	GetWorld()->LineTraceSingleByObjectType(Hit, GetPlayersLocation(), GetPlayersReach(), FCollisionObjectQueryParams(ECC_PhysicsBody), TraceParams);
	
	return Hit;
}

this is tested to work

1 Like

Interesting - thanks for the response ^,^

The enum is using old style enums that are unscoped.

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

Privacy & Terms