x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Why is InputComponent/boundkey firing without input?

In my code I've bound the letter d to my function MoveRight. I've added some AddOnScreenDebugMessages to make sure they binding functions are triggering (and they are).

My issue is that my MoveRight (and MoveLeft) functions are firing at the rate of delta time (this is an assumption, it just appears to fire at this rate) without input from the keyboard.

The function that is being called (with the contents removed except the print):

 void APlayerPawn::MoveRight(float Val){
     GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("RIGHT PRESSED"));
 }

The initialization is done this way:

 void APlayerPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent){
     check(InputComponent);
     GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("RIGHTfdsafdsafsafdRESSED"));
     InputComponent->BindAxis("MoveRight", this, &APlayerPawn::MoveRight);    
 }



If I put a break point into the MoveRight function and look at the Call Stack I can see what is calling it, but I can't figure out why.

     UE4Editor-omega_bush_2-1754.dll!APlayerPawn::MoveRight(float Val) Line 61    C++
      UE4Editor-Engine.dll!UPlayerInput::ProcessInputStack(const TArray<UInputComponent *,FDefaultAllocator> & InputComponentStack, const float DeltaTime, const bool bGamePaused) Line 998    C++
      UE4Editor-Engine.dll!APlayerController::ProcessPlayerInput(const float DeltaTime, const bool bGamePaused) Line 2147    C++
      UE4Editor-Engine.dll!APlayerController::PlayerTick(float DeltaTime) Line 1877    C++
      UE4Editor-Engine.dll!APlayerController::TickActor(float DeltaSeconds, ELevelTick TickType, FActorTickFunction & ThisTickFunction) Line 3385    C++
      UE4Editor-Engine.dll!FActorTickFunction::ExecuteTick(float DeltaTime, ELevelTick TickType, ENamedThreads::Type CurrentThread, const TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 179    C++
      UE4Editor-Engine.dll!FTickTaskSequencer::FTickFunctionTask::DoTask(ENamedThreads::Type CurrentThread, const TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 325    C++
      UE4Editor-Engine.dll!TGraphTask<FTickTaskSequencer::FTickFunctionTask>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 661    C++
      UE4Editor-Core.dll!FTaskThread::ProcessTasks(int QueueIndex, bool bAllowStall) Line 324    C++
      UE4Editor-Core.dll!FTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 176    C++
      UE4Editor-Core.dll!FTaskGraphImplementation::WaitUntilTasksComplete(const TArray<TRefCountPtr<FGraphEvent>,TInlineAllocator<4,FDefaultAllocator> > & Tasks, ENamedThreads::Type CurrentThreadIfKnown) Line 856    C++
      UE4Editor-Engine.dll!FTaskGraphInterface::WaitUntilTaskCompletes(const TRefCountPtr<FGraphEvent> & Task, ENamedThreads::Type CurrentThreadIfKnown) Line 185    C++
      UE4Editor-Engine.dll!FTickTaskSequencer::ReleaseTickGroup(ETickingGroup WorldTickGroup, bool bBlockTillComplete) Line 185    C++
      UE4Editor-Engine.dll!FTickTaskManager::RunTickGroup(ETickingGroup Group, bool bBlockTillComplete) Line 723    C++
      UE4Editor-Engine.dll!UWorld::RunTickGroup(ETickingGroup Group, bool bBlockTillComplete) Line 695    C++
      UE4Editor-Engine.dll!UWorld::Tick(ELevelTick TickType, float DeltaSeconds) Line 1127    C++
      UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1184    C++
      UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 213    C++
      UE4Editor.exe!FEngineLoop::Tick() Line 1985    C++
      UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 132    C++
      UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 196    C++
 

The file that this code is in is attached to a blueprint PL_Bush (PlayerPawn.h) which is being used as the Default Pawn Class in the GameMode.

If anyone has any information as to why this function is firing I'd greatly appreciate it. I'm afraid to dive into the source of that Call Stack.

Product Version: Not Selected
Tags:
more ▼

asked Jun 13 '14 at 04:38 PM in C++ Programming

avatar image

ghlkvf
73 4 8 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Axis are always hit as technically they will be between 0/1 or -1/1, so they always have a value. What you need to check for is if the value you are getting is not 0:

 if ((Controller != NULL) && (Value != 0.0f))
more ▼

answered Jun 13 '14 at 04:45 PM

avatar image

Dune
1.9k 53 40 200

avatar image ghlkvf Jun 13 '14 at 05:17 PM

This works. Thanks!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question