Download

How to update the camera without any axis input?

So the title might be a little bit confusing, so let me explain it.
I’m trying to achieve a lean effect, so far it works only when some Axis key is pressed or during any mouse movement.
If I activate the lean effect and stop moving and release the lean key the camera “freezes” and the next update is the default view, the default view is expected since when I release the lean key I rotate the camera back to normal.
But if I try to activate the effect while not moving nor doing any mouse movement it doesn’t work.
The code is executed but the game doesn’t update the camera rotation.
My guess is to update the camera rotation every tick, but how do I do it?

hi scrathytce in order to rotate the camera you cannot rotate the camera jaja, you need access the player controller and then rotate the camera, only the player controller have access, for get reference of player controller you can use this function taken from source:
Note: dont override this. include GameplayStatic.h on your project is a static function.


 

APlayerController* UGameplayStatics::GetPlayerController(UObject* WorldContextObject, int32 PlayerIndex ) 
{
	if (WorldContextObject)
	{
		UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject);
		if(World != nullptr)
		{
			uint32 Index = 0;
			for (FConstPlayerControllerIterator Iterator = World->GetPlayerControllerIterator(); Iterator; ++Iterator)
			{
				APlayerController* PlayerController = *Iterator;
				if (Index == PlayerIndex)
				{
					return PlayerController;
				}
				Index++;
			}
		}
	}

	return nullptr;
}



now you can rotate the camera from controller reference




APlayerController* myController = UGameplayStatics::GetPlayerController(0);
myController->SetControlRotation(FRotator(0,0,0));



Cheers