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).
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).
i have this problem UE4CC-Windows-58DC12AF4B97F057BD108FBFF569B2E9_0000
I am not able to find world outliner how to enable it?
Delay nodes occasionally don't fire the "Completed" output in a nativized build
Undefined sysmbol: typeinfo for AActor when cross-compile linux dedicated server on windows
An error occurred while trying to generate project files !?
How does UMG set overlapping layouts?
Why does the REMOVE method of map container remove elements have memory leaks?
How to achieve HLSL Multiple Render Target in Material blueprints?
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-31628 in the post.
0 |
Component | UE - Gameplay - Input |
---|---|
Affects Versions | 4.11, 4.12 |
Created | Jun 3, 2016 |
---|---|
Resolved | May 31, 2017 |
Updated | Sep 16, 2019 |