Skip to content

Commit

Permalink
Merge remote-tracking branch 'tuatec/better_client_project_support' i…
Browse files Browse the repository at this point in the history
…nto dev
  • Loading branch information
dyanikoglu committed May 11, 2021
2 parents 15e4ebb + 153f9cb commit 4ac31bc
Show file tree
Hide file tree
Showing 15 changed files with 449 additions and 54 deletions.
Binary file not shown.
Binary file modified Content/AdvancedLocomotionV4/Blueprints/UI/ALS_HUD.uasset
Binary file not shown.
24 changes: 22 additions & 2 deletions Source/ALSV4_CPP/Private/Character/ALSBaseCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "Character/Animation/ALSCharacterAnimInstance.h"
#include "Character/Animation/ALSPlayerCameraBehavior.h"
#include "Library/ALSMathLibrary.h"
#include "Components/ALSDebugComponent.h"

#include "Components/CapsuleComponent.h"
#include "Components/TimelineComponent.h"
#include "Curves/CurveFloat.h"
Expand Down Expand Up @@ -151,6 +153,8 @@ void AALSBaseCharacter::BeginPlay()
{
MainAnimInstance->SetRootMotionMode(ERootMotionMode::IgnoreRootMotion);
}

DebugComponent = FindComponentByClass<UALSDebugComponent>();
}

void AALSBaseCharacter::PreInitializeComponents()
Expand Down Expand Up @@ -752,12 +756,28 @@ void AALSBaseCharacter::SetActorLocationDuringRagdoll(float DeltaTime)
const FVector TraceVect(TargetRagdollLocation.X, TargetRagdollLocation.Y,
TargetRagdollLocation.Z - GetCapsuleComponent()->GetScaledCapsuleHalfHeight());

UWorld* World = GetWorld();
check(World);

FCollisionQueryParams Params;
Params.AddIgnoredActor(this);

FHitResult HitResult;
GetWorld()->LineTraceSingleByChannel(HitResult, TargetRagdollLocation, TraceVect,
ECC_Visibility, Params);
const bool bHit = World->LineTraceSingleByChannel(HitResult, TargetRagdollLocation, TraceVect,
ECC_Visibility, Params);

if (DebugComponent && DebugComponent->GetShowTraces())
{
UALSDebugComponent::DrawDebugLineTraceSingle(World,
TargetRagdollLocation,
TraceVect,
EDrawDebugTrace::Type::ForOneFrame,
bHit,
HitResult,
FLinearColor::Red,
FLinearColor::Green,
1.0f);
}

bRagdollOnGround = HitResult.IsValidBlockingHit();
FVector NewRagdollLoc = TargetRagdollLocation;
Expand Down
23 changes: 21 additions & 2 deletions Source/ALSV4_CPP/Private/Character/ALSPlayerCameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "Character/ALSBaseCharacter.h"
#include "Character/ALSPlayerController.h"
#include "Character/Animation/ALSPlayerCameraBehavior.h"
#include "Components/ALSDebugComponent.h"

#include "Kismet/KismetMathLibrary.h"


Expand Down Expand Up @@ -61,6 +63,8 @@ void AALSPlayerCameraManager::OnPossess(AALSBaseCharacter* NewCharacter)
const FVector& TPSLoc = ControlledCharacter->GetThirdPersonPivotTarget().GetLocation();
SetActorLocation(TPSLoc);
SmoothedPivotTarget.SetLocation(TPSLoc);

DebugComponent = ControlledCharacter->FindComponentByClass<UALSDebugComponent>();
}

float AALSPlayerCameraManager::GetCameraBehaviorParam(FName CurveName) const
Expand Down Expand Up @@ -183,8 +187,23 @@ bool AALSPlayerCameraManager::CustomCameraBehavior(float DeltaTime, FVector& Loc
Params.AddIgnoredActor(ControlledCharacter);

FHitResult HitResult;
World->SweepSingleByChannel(HitResult, TraceOrigin, TargetCameraLocation, FQuat::Identity,
TraceChannel, FCollisionShape::MakeSphere(TraceRadius), Params);
const FCollisionShape SphereCollisionShape = FCollisionShape::MakeSphere(TraceRadius);
const bool bHit = World->SweepSingleByChannel(HitResult, TraceOrigin, TargetCameraLocation, FQuat::Identity,
TraceChannel, SphereCollisionShape, Params);

if (DebugComponent && DebugComponent->GetShowTraces())
{
UALSDebugComponent::DrawDebugSphereTraceSingle(World,
TraceOrigin,
TargetCameraLocation,
SphereCollisionShape,
EDrawDebugTrace::Type::ForOneFrame,
bHit,
HitResult,
FLinearColor::Red,
FLinearColor::Green,
5.0f);
}

if (HitResult.IsValidBlockingHit())
{
Expand Down
18 changes: 10 additions & 8 deletions Source/ALSV4_CPP/Private/Character/ALSPlayerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ void AALSPlayerController::SetupDebugInputs()
UALSDebugComponent* DebugComp = Cast<UALSDebugComponent>(Comp);
if (InputComponent && DebugComp)
{
InputComponent->BindKey(FKey("Tab"), EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleHud);
InputComponent->BindKey(FKey("V"), EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleDebugView);
InputComponent->BindKey(FKey("T"), EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleTraces);
InputComponent->BindKey(FKey("Y"), EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleDebugShapes);
InputComponent->BindKey(FKey("U"), EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleLayerColors);
InputComponent->BindKey(FKey("I"), EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleCharacterInfo);
InputComponent->BindKey(FKey("Z"), EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleSlomo);
InputComponent->BindKey(FKey("M"), EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleDebugMesh);
InputComponent->BindKey(EKeys::Tab, EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleHud);
InputComponent->BindKey(EKeys::V, EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleDebugView);
InputComponent->BindKey(EKeys::T, EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleTraces);
InputComponent->BindKey(EKeys::Y, EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleDebugShapes);
InputComponent->BindKey(EKeys::U, EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleLayerColors);
InputComponent->BindKey(EKeys::I, EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleCharacterInfo);
InputComponent->BindKey(EKeys::Z, EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleSlomo);
InputComponent->BindKey(EKeys::Comma, EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::PreviousFocusedDebugCharacter);
InputComponent->BindKey(EKeys::Period, EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::NextFocusedDebugCharacter);
InputComponent->BindKey(EKeys::M, EInputEvent::IE_Pressed, DebugComp, &UALSDebugComponent::ToggleDebugMesh);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "Character/Animation/ALSCharacterAnimInstance.h"
#include "Character/ALSBaseCharacter.h"
#include "Library/ALSMathLibrary.h"
#include "Components/ALSDebugComponent.h"

#include "Curves/CurveVector.h"
#include "Components/CapsuleComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
Expand Down Expand Up @@ -53,6 +55,17 @@ void UALSCharacterAnimInstance::NativeInitializeAnimation()
Character = Cast<AALSBaseCharacter>(TryGetPawnOwner());
}

void UALSCharacterAnimInstance::NativeBeginPlay()
{
// it seems to be that the player pawn components are not really initialized
// when the call to NativeInitializeAnimation() happens.
// This is the reason why it is tried here to get the ALS debug component.
if (APawn* Owner = TryGetPawnOwner())
{
DebugComponent = Owner->FindComponentByClass<UALSDebugComponent>();
}
}

void UALSCharacterAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{
Super::NativeUpdateAnimation(DeltaSeconds);
Expand Down Expand Up @@ -458,11 +471,28 @@ void UALSCharacterAnimInstance::SetFootOffsets(float DeltaSeconds, FName EnableF
FCollisionQueryParams Params;
Params.AddIgnoredActor(Character);

const FVector TraceStart = IKFootFloorLoc + FVector(0.0, 0.0, Config.IK_TraceDistanceAboveFoot);
const FVector TraceEnd = IKFootFloorLoc - FVector(0.0, 0.0, Config.IK_TraceDistanceBelowFoot);

FHitResult HitResult;
World->LineTraceSingleByChannel(HitResult,
IKFootFloorLoc + FVector(0.0, 0.0, Config.IK_TraceDistanceAboveFoot),
IKFootFloorLoc - FVector(0.0, 0.0, Config.IK_TraceDistanceBelowFoot),
ECC_Visibility, Params);
const bool bHit = World->LineTraceSingleByChannel(HitResult,
TraceStart,
TraceEnd,
ECC_Visibility, Params);

if (DebugComponent && DebugComponent->GetShowTraces())
{
UALSDebugComponent::DrawDebugLineTraceSingle(
World,
TraceStart,
TraceEnd,
EDrawDebugTrace::Type::ForOneFrame,
bHit,
HitResult,
FLinearColor::Red,
FLinearColor::Green,
5.0f);
}

FRotator TargetRotOffset = FRotator::ZeroRotator;
if (Character->GetCharacterMovement()->IsWalkable(HitResult))
Expand Down Expand Up @@ -769,11 +799,25 @@ float UALSCharacterAnimInstance::CalculateLandPrediction() const
Params.AddIgnoredActor(Character);

FHitResult HitResult;

World->SweepSingleByChannel(HitResult, CapsuleWorldLoc, CapsuleWorldLoc + TraceLength, FQuat::Identity,
ECC_Visibility,
FCollisionShape::MakeCapsule(CapsuleComp->GetUnscaledCapsuleRadius(),
CapsuleComp->GetUnscaledCapsuleHalfHeight()), Params);
const FCollisionShape CapsuleCollisionShape = FCollisionShape::MakeCapsule(CapsuleComp->GetUnscaledCapsuleRadius(),
CapsuleComp->GetUnscaledCapsuleHalfHeight());
const float HalfHeight = 0.0f;
const bool bHit = World->SweepSingleByChannel(HitResult, CapsuleWorldLoc, CapsuleWorldLoc + TraceLength, FQuat::Identity,
ECC_Visibility, CapsuleCollisionShape, Params);

if (DebugComponent && DebugComponent->GetShowTraces())
{
UALSDebugComponent::DrawDebugCapsuleTraceSingle(World,
CapsuleWorldLoc,
CapsuleWorldLoc + TraceLength,
CapsuleCollisionShape,
EDrawDebugTrace::Type::ForOneFrame,
bHit,
HitResult,
FLinearColor::Red,
FLinearColor::Green,
5.0f);
}

if (Character->GetCharacterMovement()->IsWalkable(HitResult))
{
Expand Down
Loading

0 comments on commit 4ac31bc

Please sign in to comment.