From 0fef86b47dd7d55b443c0ac02a9e7b35fffdcf9f Mon Sep 17 00:00:00 2001 From: corinv Date: Wed, 18 Apr 2018 11:29:24 +0100 Subject: [PATCH] Char: no longer can jump during slide, also fixed camera jerk that was added to slide --- .../Blueprints/ThirdPersonCharacter.uasset | 4 ++-- .../ParkourGame/Private/ParkourGameCharacter.cpp | 14 +++++++++++--- .../ParkourGame/Private/ParkourGameCharacter.h | 4 +++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ParkourGame/Content/ThirdPersonCPP/Blueprints/ThirdPersonCharacter.uasset b/ParkourGame/Content/ThirdPersonCPP/Blueprints/ThirdPersonCharacter.uasset index 36e3908..6ca3d68 100644 --- a/ParkourGame/Content/ThirdPersonCPP/Blueprints/ThirdPersonCharacter.uasset +++ b/ParkourGame/Content/ThirdPersonCPP/Blueprints/ThirdPersonCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:454d4c68889099abd0d9ed91fd052133fd7efe877db59bf8f6a62a28aa3bf9de -size 1052896 +oid sha256:a368b279580e57b449a3fca0696c7ba4a6cd439f38b8891b8f6613095af1d884 +size 1064945 diff --git a/ParkourGame/Source/ParkourGame/Private/ParkourGameCharacter.cpp b/ParkourGame/Source/ParkourGame/Private/ParkourGameCharacter.cpp index 1315159..bc93900 100644 --- a/ParkourGame/Source/ParkourGame/Private/ParkourGameCharacter.cpp +++ b/ParkourGame/Source/ParkourGame/Private/ParkourGameCharacter.cpp @@ -940,9 +940,11 @@ void AParkourGameCharacter::SetRagdollOnBodyPart_Implementation(EBodyPart Part, OnRep_RagdollState(); } -bool AParkourGameCharacter::SetFullRagdoll_Validate(bool bIsFullRagdoll) { return true; } -void AParkourGameCharacter::SetFullRagdoll_Implementation(bool bIsFullRagdoll) +bool AParkourGameCharacter::SetFullRagdoll_Validate(bool bIsFullRagdoll, bool bFromSlide) { return true; } +void AParkourGameCharacter::SetFullRagdoll_Implementation(bool bIsFullRagdoll, bool bFromSlide) { + + bWasSliding = bFromSlide; m_RagdollState[(int32)EBodyPart::MAX] = bIsFullRagdoll ? 1 : 0; OnRep_RagdollState(); OnRagdoll.Broadcast(); @@ -1182,9 +1184,15 @@ void AParkourGameCharacter::CapsuleToRagdoll() { USkeletalMeshComponent* PlayerMesh = GetSkeletalMesh(); if (m_RagdollState[(int32)EBodyPart::MAX] > 0) { + //handle capsule position differently if sliding, for the camera's sake + FVector offset = FVector(0.0, 0.0, 0.0); + if (bWasSliding) { + offset = FVector(0.0, 0.0, 97.0); + } + FVector SocketLocation = PlayerMesh->GetSocketLocation(UParkourHelperLibrary::GetRootBoneForBodyPart(EBodyPart::Pelvis)); UCapsuleComponent* Capsule = GetCapsuleComponent(); - Capsule->SetWorldLocation(SocketLocation); + Capsule->SetWorldLocation(SocketLocation + offset); } } diff --git a/ParkourGame/Source/ParkourGame/Private/ParkourGameCharacter.h b/ParkourGame/Source/ParkourGame/Private/ParkourGameCharacter.h index 04b271b..5f7f3ca 100644 --- a/ParkourGame/Source/ParkourGame/Private/ParkourGameCharacter.h +++ b/ParkourGame/Source/ParkourGame/Private/ParkourGameCharacter.h @@ -402,7 +402,7 @@ class AParkourGameCharacter : public ACharacter void SetRagdollOnBodyPart(EBodyPart Part, bool bNewRagdoll); UFUNCTION(BlueprintCallable, Category = "Physics", Server, Reliable, WithValidation) - void SetFullRagdoll(bool bIsFullRagdoll); + void SetFullRagdoll(bool bIsFullRagdoll, bool bFromSlide = false); UFUNCTION(BlueprintPure, Category = "Physics") bool IsFullRagdoll() const; @@ -432,6 +432,7 @@ class AParkourGameCharacter : public ACharacter UFUNCTION() void OnGameOver(AMiniGameBase* Game, EMiniGameEndReason Reason); + UFUNCTION(BlueprintCallable, Category = "CharacterState") void EnableJumping(bool Enable = true); private: @@ -483,5 +484,6 @@ class AParkourGameCharacter : public ACharacter class AParkourPlayerState* ParkourPlayerState; bool bCanJump = true; + bool bWasSliding = false; };