Skip to content

Commit

Permalink
Fix camera shake in fist pirson view mode.
Browse files Browse the repository at this point in the history
I have add new animation. And add camera lag for prevent camera shake.
  • Loading branch information
Deema35 committed Sep 8, 2018
1 parent 20a8276 commit 2311c04
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 31 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@ Saved/*
Build/*

# Cache files for the editor to use
DerivedDataCache/*
DerivedDataCache/*

#Plugin directory
Plugins/ClimbingPawnMovementComponent/Intermediate/*
Plugins/ClimbingPawnMovementComponent/Binaries/*
!Plugins/ClimbingPawnMovementComponent/Binaries/Win64/*.dll
4 changes: 2 additions & 2 deletions Binaries/Win64/ClimbingSystemEditor.target
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
{
"MajorVersion": 4,
"MinorVersion": 20,
"PatchVersion": 1,
"Changelist": 4233996,
"PatchVersion": 2,
"Changelist": 4302132,
"CompatibleChangelist": 4212847,
"IsLicenseeVersion": 0,
"IsPromotedBuild": 1,
Expand Down
Binary file modified Binaries/Win64/UE4Editor-ClimbingSystem.dll
Binary file not shown.
Binary file modified Content/Animations/Maniqin/IdleRun2D.uasset
Binary file not shown.
Binary file not shown.
Binary file modified Content/Blueprints/ClimbinCharBP.uasset
Binary file not shown.
Binary file removed Content/LadderSkelton_Skeleton.uasset
Binary file not shown.
Binary file modified Content/Mannequin/Mesh/UE4_Mannequin_Skeleton.uasset
Binary file not shown.
Binary file added Content/Skel_Skeleton.uasset
Binary file not shown.
Binary file modified Content/ThirdPersonBP/Maps/ThirdPersonExampleMap.umap
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,54 @@ AClimbingCharacter::AClimbingCharacter(const FObjectInitializer& ObjectInitializ

TArray<USkeletalMeshComponent*> Components;
GetComponents<USkeletalMeshComponent>(Components);
ClimbMesh = Components[0];

TArray<UCapsuleComponent*> ComponentsCaps;
GetComponents<UCapsuleComponent>(ComponentsCaps);
ClimbCapsule = ComponentsCaps[0];
USkeletalMeshComponent* ClimbMesh = Components[0];


//Add Camera
CameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArm"));
CameraSpringArm->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
CameraSpringArm->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, 8.0f), FRotator(0.0f, 0.0f, 0.0f));
CameraSpringArm->TargetArmLength = 300.f;
CameraSpringArm->bUsePawnControlRotation = true;
//Add Thrid pirson Camera arm
ThridCameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("ThridCameraSpringArm"));
ThridCameraSpringArm->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
ThridCameraSpringArm->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, 8.0f), FRotator(0.0f, 0.0f, 0.0f));
ThridCameraSpringArm->TargetArmLength = 300.f;
ThridCameraSpringArm->bUsePawnControlRotation = true;

//Add Fist pirson Camera arm
FistCameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("FistCameraSpringArm"));
FistCameraSpringArm->AttachToComponent(ClimbMesh, FAttachmentTransformRules::KeepRelativeTransform, FName("head"));
FistCameraSpringArm->SetRelativeLocationAndRotation(FVector(0.0f, 12.0f, 0.0f), FRotator(0.0f, 90.0f, 270.0f));
FistCameraSpringArm->TargetArmLength = 0;
FistCameraSpringArm->bUsePawnControlRotation = true;
FistCameraSpringArm->bEnableCameraLag = true;

FistCameraSpringArm->CameraLagSpeed = 65;
FistCameraSpringArm->CameraLagMaxTimeStep = 0.5;

if (ClimbingMovement->GetCurrentClimbingMode() != EClimbingPawnModeType::Climb)
{
bUseControllerRotationYaw = true;
ClimbingMovement->bOrientRotationToMovement = false;

}

//AddCamera
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("ClimbCamera"));
Camera->AttachToComponent(CameraSpringArm, FAttachmentTransformRules::KeepRelativeTransform, USpringArmComponent::SocketName);
Camera->bUsePawnControlRotation = true;
bUseControllerRotationYaw = false;

Camera->bUsePawnControlRotation = true;

if (bFistPirsonView)
{
Camera->AttachToComponent(FistCameraSpringArm, FAttachmentTransformRules::KeepRelativeTransform, USpringArmComponent::SocketName);

bUseControllerRotationYaw = true;
ClimbingMovement->bOrientRotationToMovement = false;

}
else
{
Camera->AttachToComponent(ThridCameraSpringArm, FAttachmentTransformRules::KeepRelativeTransform, USpringArmComponent::SocketName);

bUseControllerRotationYaw = false;
ClimbingMovement->bOrientRotationToMovement = true;
}


}
Expand Down Expand Up @@ -261,12 +290,12 @@ void AClimbingCharacter::ChangeView(bool FistPirson)
{
if (FistPirson == bFistPirsonView) return;

Camera->DetachFromComponent(FDetachmentTransformRules::KeepWorldTransform);

if (FistPirson)
{
Camera->DetachFromComponent(FDetachmentTransformRules::KeepWorldTransform);
Camera->AttachToComponent(ClimbMesh, FAttachmentTransformRules::KeepRelativeTransform, FName("head"));
GetWorld()->GetFirstPlayerController()->SetControlRotation(GetActorRotation());
Camera->SetRelativeLocation(FVector(0, 10, 0));
Camera->AttachToComponent(FistCameraSpringArm, FAttachmentTransformRules::SnapToTargetNotIncludingScale, FName("SpringEndpoint"));

bFistPirsonView = true;

if (ClimbingMovement->GetCurrentClimbingMode() != EClimbingPawnModeType::Climb)
Expand All @@ -278,9 +307,10 @@ void AClimbingCharacter::ChangeView(bool FistPirson)
}
else
{
Camera->DetachFromComponent(FDetachmentTransformRules::KeepWorldTransform);
Camera->AttachToComponent(CameraSpringArm, FAttachmentTransformRules::SnapToTargetNotIncludingScale, FName("SpringEndpoint"));
Camera->AttachToComponent(ThridCameraSpringArm, FAttachmentTransformRules::SnapToTargetNotIncludingScale, FName("SpringEndpoint"));

bFistPirsonView = false;

if (ClimbingMovement->GetCurrentClimbingMode() != EClimbingPawnModeType::Climb)
{
bUseControllerRotationYaw = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ enum class EPointLocation : uint8
UCLASS()
class CLIMBINGPAWNMOVEMENTCOMPONENTRUNTIME_API AClimbingCharacter : public ACharacter
{
friend class UClimbingPawnMovementComponent;

GENERATED_BODY()
public:

UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly)
class USpringArmComponent* CameraSpringArm;
class USpringArmComponent* ThridCameraSpringArm;

UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly)
class USpringArmComponent* FistCameraSpringArm;

UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly)
class UCameraComponent* Camera;

Expand Down Expand Up @@ -83,7 +89,7 @@ class CLIMBINGPAWNMOVEMENTCOMPONENTRUNTIME_API AClimbingCharacter : public AChar

public:

bool bFistPirsonView;
bool bFistPirsonView = true;

class AOverlapObject* OverlopObject;

Expand All @@ -92,12 +98,6 @@ class CLIMBINGPAWNMOVEMENTCOMPONENTRUNTIME_API AClimbingCharacter : public AChar
UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class UClimbingPawnMovementComponent* ClimbingMovement;

USkeletalMeshComponent* ClimbMesh;

UCapsuleComponent* ClimbCapsule;

friend class UClimbingPawnMovementComponent;

float LeftYawRange;

float RightYawRange;
Expand Down

0 comments on commit 2311c04

Please sign in to comment.