It appears that FSlateApplication::OnControllerAnalog triggers a left mouse click to occur on mobile platforms. If developers haven't properly avoided hooking up delegates to the InputComponent for mouse, then this can cause issues (in the case of FirstPersonShooter, the OnFire method is called).

Steps to Reproduce

1. Create a new C++ project based on first person shooter.

2. Create an new Action Key Binding called "CallSlate".

3. In the FirstPersonCharacter class, add the following method:

// In the Header file:
void OnTouchCube();

// In the Source file:
// Need these extra includes
#include "SlateBasics.h"
#include "SlateExtras.h"
void AFirstPersonCharacter::OnTouchCube()
    FSlateApplication::Get().OnControllerAnalog(FGamepadKeyNames::LeftAnalogX, 0, 0);


4. In the SetupInputPlayerComponent, comment the following lines.

//InputComponent->BindTouch(EInputEvent::IE_Pressed, this, &AFiredCharacter::TouchStarted);
// Comment out the if statement, but leave the brackets.
// if (EnableTouchscreenMovement(InputComponent) == false)
    InputComponent->BindAction("Fire", IE_Pressed, this, &AFiredCharacter::OnFire);

5. Modify the FirstPerson.Build.cs file to include slate dependencies:

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class FirstPerson : ModuleRules
	public FirstPerson(TargetInfo Target)
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Slate", "SlateCore" });

6. Recompile the code.
7. Back in the editor, select one of the StaticMeshActor cubes and add a Blueprint to it. See the below Blueprint (where MyProjectCharacter == FirstPersonCharacter).

8. Play in a Mobile Preview editor.
9. Move to the cube and click.

Expected: Nothing interesting happens.
Actual: AFirstPersonCharacter::OnFire is called. (This may take a few attempts to correctly align the mouse).

Have Comments or More Details?

There's no existing public thread on this issue, so head over toAnswerHub just mention UE-31628 in the post.

Login to Vote

Won't Fix
ComponentGameplay - Input
Affects Versions4.114.12
CreatedJun 3, 2016
ResolvedMay 31, 2017
UpdatedSep 16, 2019