I am trying to create a touch button for a mobile game HUD.
I am not sure if this is the best way to do or if I am doing it the correctly or now.
I am using c++ to do it.
First I created an actor having a box component and a static mesh component.
Then I use the delegate on the box component
UPROPERTY(BlueprintAssignable, Category="Input|Touch Input") FComponentOnInputTouchBeginSignature OnInputTouchBegin;
to detect touch.
To place this button on the camera location I use tick function and deproject from camera. Find the location and rotation of the camera and move the the actor to that location.
Is the best way to create touch HUD for mobile?
My another question is how can i know the location of touch on screen. If suppose I want to drag something on screen how do I do it?
I found something called hitbox in the HUD class. Can these be used to create click-able HUDs?
/** * Add a hitbox to the hud * @param Position Coordinates of the top left of the hit box. * @param Size Size of the hit box. * @param Name Name of the hit box. * @param bConsumesInput Whether click processing should continue if this hit box is clicked. * @param Priority The priority of the box used for layering. Larger values are considered first. Equal values are considered in the order they were added. */ UFUNCTION(BlueprintCallable, Category=HUD, meta=(InPriority="0")) void AddHitBox(FVector2D Position, FVector2D Size, FName Name, bool bConsumesInput, int32 Priority = 0);