Add Input on Tick not working, why?

Guys this bug still happens in the 4.16.2. After digging in the engine source code I found out that the RotationInput variable (Used by AddYawInput/AddPitchInput/AddRowInput and alike to store the rotation) was getting cleared after calling the Tick function. So calling these functions inside tick won’t work at all.

The workaround is to call AddPitchInput before or after the PlayersController’s EventTick function.

Here’s what I have done:

  1. Create a component called “TickPrerequisiteComponent”
  2. Add a single EventDispatcher to this component called “OverrideEventTick” function must be called by “TickPrerequisiteComponent” every frame on the EventTick

203232-tickoverride.jpg

  1. After that is only a matter to bind some function to it
  2. You can also make sure the component Tick order by using the function AddTickPrerequisiteComponent. I guess this step is not necessary.

In c++ you can call UpdateRotation(DeltaTime); inside Tick event of player controller after adding pitch/yaw/roll inputs.

You can also directly override UpdateRotation and add your rotation inputs right there before calling Super::UpdateRotation. this will avoid calling UpdateRotation twice.

1 Like