Since I had some interviews I haven't had much time to code. Therefore I created a simple player lean that rotates and pushes the player character out to the left and right if the Q and E button is pressed. When either of these is pressed then the player resets back to the original position.
void AWeapon_PrototypeCharacter::LeanPl(float locationNewY, float rotationNewY)
{
FVector EndVector = FirstPersonCameraComponent->GetRelativeLocation();
EndVector.Y = EndVector.Y + locationNewY;
FRotator TransformRotator = FirstPersonCameraComponent->GetRelativeRotation();
TransformRotator.Roll = TransformRotator.Roll + rotationNewY;
FirstPersonCameraComponent->SetRelativeLocationAndRotation(EndVector, TransformRotator);
Mesh1P->SetRelativeRotation(TransformRotator);
}
void AWeapon_PrototypeCharacter::ResetPlayerLean()
{
UE_LOG(LogTemp, Warning, TEXT("ResetPlayerLean: Hit"));
FirstPersonCameraComponent->SetRelativeLocationAndRotation(DefualtPlPos, DefaultPlRot);
Mesh1P->SetRelativeRotation(DefaultPlRot);
bisLeaning = false;
}
void AWeapon_PrototypeCharacter::PlayerLeanRight()
{
if (bisLeaning == false)
{
UE_LOG(LogTemp, Warning, TEXT("LeanRight: Hit"));
LeanPl(LeanLeftValue, LeanLeftRotationValue);
bisLeaning = true;
}
else
{
ResetPlayerLean();
}
}
void AWeapon_PrototypeCharacter::PlayerLeanLeft()
{
if (bisLeaning == false)
{
UE_LOG(LogTemp, Warning, TEXT("LeanLeft: Hit"));
LeanPl(LeanRightValue, LeanRightRotationValue);
bisLeaning = true;
}
else
{
ResetPlayerLean();
}
}
This lets the player look around corners. Next project I am going to do is Random Map Generation.