diff --git a/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_B_Montage.uasset b/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_B_Montage.uasset index 0f95dc3..e1a32bd 100644 --- a/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_B_Montage.uasset +++ b/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_B_Montage.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:087abb836bf20d8e74b735e415b027a4eb3ecbfb4c0ab46529e89f65aae91644 -size 96184 +oid sha256:78a8ef99dbb6df762929410d05c4a56ceae93b7ecbf58aafdfa403016ece0b85 +size 96705 diff --git a/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_F_Montage.uasset b/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_F_Montage.uasset index 8338975..b5a3b32 100644 --- a/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_F_Montage.uasset +++ b/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_F_Montage.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4b4192666f769d3ab6668304682615c4e9094f66d97282c1c2f4cb5f69d4863f -size 94759 +oid sha256:cea102b3996610d88fdb518eaafa8cdcae75e54e22e18754a16bf62ca452415a +size 95496 diff --git a/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_L_Montage.uasset b/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_L_Montage.uasset index fe01137..3cd1254 100644 --- a/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_L_Montage.uasset +++ b/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_L_Montage.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5808507ebe203db589896e69b275fed1fad145f98f647c8edbab1ec4aa23a574 -size 97348 +oid sha256:d04f22dc554c864650329ca1ab2d5017422e83289d9d013349eddfb8a6630c83 +size 97953 diff --git a/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_R_Montage.uasset b/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_R_Montage.uasset index a07151f..8e0b092 100644 --- a/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_R_Montage.uasset +++ b/SwordNGun/Content/Characters/Protagonist/Animations/NEW/Dash/Dash_Step_R_Montage.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2659a534c3a8d503a56028a015208d9705efdb8f22461fd9743f3302b619319d -size 97932 +oid sha256:d76f912a13811e31305d105c3dfac9fe6ceb7ab1a49e7db1ad167dcf4a5adee7 +size 98461 diff --git a/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset b/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset index 1d767dd..fa96808 100644 --- a/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset +++ b/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f18350e99fafc6adc404bb0a13a1c57fa6b1d152452c0204b9909ae17a885169 -size 184885 +oid sha256:bebc7a07883dfb1c5a19300b03ac0e0cfe6319dd7fa9adc8ffe6545776dd26da +size 184810 diff --git a/SwordNGun/Source/SwordNGun/Private/Components/SNGCharacterMovementComponent.cpp b/SwordNGun/Source/SwordNGun/Private/Components/SNGCharacterMovementComponent.cpp index 2bca96a..f38d392 100644 --- a/SwordNGun/Source/SwordNGun/Private/Components/SNGCharacterMovementComponent.cpp +++ b/SwordNGun/Source/SwordNGun/Private/Components/SNGCharacterMovementComponent.cpp @@ -78,10 +78,12 @@ void USNGCharacterMovementComponent::RestoreMovementDefaults() void USNGCharacterMovementComponent::Dash() { - GroundFriction = DashGroundFriction; - GravityScale = DashGravityScale; - FloatTime = DashFloatTime; - SlideTime = DashSlideTime; + FLaunchParameters LaunchParams; + LaunchParams.bOverrideMovementMode = false; + LaunchParams.GroundFriction = DashGroundFriction; + LaunchParams.GravityScale = DashGravityScale; + LaunchParams.FloatTime = DashFloatTime; + LaunchParams.SlideTime = DashSlideTime; // sets gravity and friction targets which will start interpolating after float time and slide time elapse respectively TargetGravityScale = DefaultGravityScale; @@ -92,7 +94,9 @@ void USNGCharacterMovementComponent::Dash() FRotator CharacterRot = FRotator(0.0f, GetCharacterOwner()->GetActorRotation().Yaw, 0.0f); FVector LaunchDir = FVector(UKismetMathLibrary::GetForwardVector(CharacterRot)); LaunchDir.Normalize(); - Launch(LaunchDir * DashVelocity); + + LaunchParams.Velocity = LaunchDir * DashVelocity; + LaunchCharacter(LaunchParams); } #if WITH_EDITOR @@ -124,6 +128,21 @@ void USNGCharacterMovementComponent::OnSprintTimer() TargetMaxWalkSpeed = SprintingMaxWalkSpeed; } +void USNGCharacterMovementComponent::LaunchCharacter(FLaunchParameters& LaunchParams) +{ + GroundFriction = LaunchParams.GroundFriction; + GravityScale = LaunchParams.GravityScale; + FloatTime = LaunchParams.FloatTime; + SlideTime = LaunchParams.SlideTime; + + Velocity = LaunchParams.Velocity; + + if(LaunchParams.bOverrideMovementMode) + { + SetMovementMode(LaunchParams.NewMovementMode); + } +} + void USNGCharacterMovementComponent::ComputeGravityScaleAndJumpZVelocity() { float HalfJumpDuration = DesiredJumpDuration / 2.0f; @@ -206,6 +225,8 @@ void USNGCharacterMovementComponent::TickComponent(float DeltaTime, ELevelTick T { Super::TickComponent(DeltaTime, Tick, ThisTickFunction); + // turning off sprinting for now...not a HUGE fan of this implementation + /* float LateralSpeed = Velocity.Size2D(); if(LateralSpeed >= SprintLateralSpeedThreshold && !GetWorld()->GetTimerManager().IsTimerActive(TimerHandle_SprintTimer)) { @@ -224,6 +245,7 @@ void USNGCharacterMovementComponent::TickComponent(float DeltaTime, ELevelTick T TargetMaxWalkSpeed = DefaultMaxWalkSpeed; MaxWalkSpeedInterpSpeed = WalkToSprintInterpSpeed; } + */ InterpolateMovementParameters(DeltaTime); } diff --git a/SwordNGun/Source/SwordNGun/Public/Components/SNGCharacterMovementComponent.h b/SwordNGun/Source/SwordNGun/Public/Components/SNGCharacterMovementComponent.h index 566dbba..e570a1d 100644 --- a/SwordNGun/Source/SwordNGun/Public/Components/SNGCharacterMovementComponent.h +++ b/SwordNGun/Source/SwordNGun/Public/Components/SNGCharacterMovementComponent.h @@ -6,6 +6,51 @@ #include "GameFramework/CharacterMovementComponent.h" #include "SNGCharacterMovementComponent.generated.h" +USTRUCT(BlueprintType) +struct FLaunchParameters +{ + GENERATED_BODY() + + /** Velocity */ + UPROPERTY() + FVector Velocity; + + /** Should the character's movement mode change after being launched? */ + UPROPERTY(BlueprintReadWrite) + bool bOverrideMovementMode; + + /** What the character's movement mode will be set to after launch. This will only be set is bOverrideMovementMode is true. */ + UPROPERTY(BlueprintReadWrite) + TEnumAsByte NewMovementMode; + + /** The ground friction that should be immediately applied when the character is launched */ + UPROPERTY(BlueprintReadWrite) + float GroundFriction; + + /** The gravity scale that should be immediately applied when the character is launched */ + UPROPERTY(BlueprintReadWrite) + float GravityScale; + + /** The float time that should be immediately applied when the character is launched */ + UPROPERTY(BlueprintReadWrite) + float FloatTime; + + /** The slide time that should be immediately applied when the character is launched */ + UPROPERTY(BlueprintReadWrite) + float SlideTime; + + FLaunchParameters() + : Velocity(FVector::ZeroVector) + , bOverrideMovementMode(false) + , NewMovementMode(EMovementMode::MOVE_Walking) + , GroundFriction(8.0f) + , GravityScale(1.0f) + , FloatTime(0.0f) + , SlideTime(0.0f) + { + } +}; + /** * Class that extends UE CharacterMovementComponent to add SNG specific functionality * @@ -134,6 +179,8 @@ protected: /** Timer used to determine when to start interpolating GravityScale back to TargetGravityScale */ UPROPERTY(BlueprintReadWrite) float FloatTime; + + void LaunchCharacter(FLaunchParameters& LaunchParams); /** * How high (Z) is the character able to reach when holding the jump button for the maximum allowed time.