I posted something similar days ago but no one answered, I hope someone can help me now.
This is becoming frustrating. Let me explain what I want to do:
-Camera Bobs (Idle, Walk & Run)
Whenever I walk, the player doesn’t perform the specific camera bob, it stays with the “IdleBob” it doesn’t perform the “WalkBob” I created. Im a c++ noob but here is my code:
.h
//Sprint
void Sprint();
void StopSprint();
//Idle
void Idle();
/** Handles moving forward/backward */
void MoveForward(float Val);
/** Handles stafing movement, left and right */
void MoveRight(float Val);
the last 2 functions are the default funcs that come with the FPP Template.
.cpp
#pragma region Movement
void ALevelsGameCharacter::Sprint()
{
if (InputComponent->GetAxisValue("MoveForward") < 0)
return;
APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
if ((InputComponent->GetAxisValue("MoveForward")) || (InputComponent->GetAxisValue("MoveRight")))
{
GetCharacterMovement()->MaxWalkSpeed = 750.0f;
PC->ClientPlayCameraAnim(SprintBob, 0.50f, 1.0f, 0.5f, 1.0f, true, false, ECameraAnimPlaySpace::CameraLocal, FRotator(0.0f, 0.0f, 0.0f));
}
}
void ALevelsGameCharacter::StopSprint()
{
APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
GetCharacterMovement()->MaxWalkSpeed = 300.0f;
PC->ClientStopCameraAnim(SprintBob);
PC->ClientStopCameraAnim(WalkBob);
}
void ALevelsGameCharacter::MoveForward(float Value)
{
APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
PC->ClientStopCameraAnim(IdleBob);
if ((Value != 0.0f))
{
// add movement in that direction
AddMovementInput(GetActorForwardVector(), Value);
PC->ClientPlayCameraAnim(WalkBob, 0.5f, Value, 0.25f, 1.0f, true, true, ECameraAnimPlaySpace::CameraLocal, FRotator(0.0f, 0.0f, 0.0f));
}
else
Idle();
}
void ALevelsGameCharacter::MoveRight(float Value)
{
APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
if ((Value != 0.0f))
{
// add movement in that direction
AddMovementInput(GetActorRightVector(), Value);
if (!InputComponent->GetAxisValue("MoveForward"))
PC->ClientPlayCameraAnim(WalkBob, 0.5f, Value, 0.25f, 1.0f, true, true, ECameraAnimPlaySpace::CameraLocal, FRotator(0.0f, 0.0f, 0.0f));
}
else
Idle();
}
void ALevelsGameCharacter::Idle()
{
APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
PC->ClientPlayCameraAnim(IdleBob, 0.5f, 1.0f, 0.25f, 1.0f, true, true, ECameraAnimPlaySpace::CameraLocal, FRotator(0.0f, 0.0f, 0.0f));
}
#pragma endregion
So what I want is:
-When the player is not moving, it will perform the “IdleBob”
-When the player is moving, the engine will perform the “WalkBob”
-And when the player is running, well… you know whats next.
Sorry for being a noob, and about my english. Thanks