Jump in direction of player input
This commit is contained in:
		
							parent
							
								
									32531fbcf4
								
							
						
					
					
						commit
						c9fb74b90d
					
				
							
								
								
									
										
											BIN
										
									
								
								SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							@ -69,6 +69,7 @@ ASNGCharacterBase::ASNGCharacterBase(const FObjectInitializer& ObjectInitializer
 | 
				
			|||||||
		UE_LOG(LogTemp, Warning, TEXT("SNGCharacterBase :: Could not get skeletal mesh. Did you forget to set it?"));
 | 
							UE_LOG(LogTemp, Warning, TEXT("SNGCharacterBase :: Could not get skeletal mesh. Did you forget to set it?"));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						InputThreshold = 0.1f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DefaultFOV = 90.0f;
 | 
						DefaultFOV = 90.0f;
 | 
				
			||||||
	SprintFOV = 110.0f;
 | 
						SprintFOV = 110.0f;
 | 
				
			||||||
@ -206,29 +207,52 @@ void ASNGCharacterBase::Tick(float DeltaTime)
 | 
				
			|||||||
	if(CharacterMovementDebug)
 | 
						if(CharacterMovementDebug)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		float LateralSpeed = GetVelocity().Size2D();
 | 
							float LateralSpeed = GetVelocity().Size2D();
 | 
				
			||||||
 | 
							FVector VelocityDir = GetVelocity();
 | 
				
			||||||
 | 
							VelocityDir.Normalize();
 | 
				
			||||||
 | 
							FVector LateralVelocityDir = FVector(VelocityDir.X, VelocityDir.Y, 0.0f); 
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		FVector StartPos(GetActorLocation().X,
 | 
							FVector StartPos(GetActorLocation().X,
 | 
				
			||||||
						 GetActorLocation().Y,
 | 
											 GetActorLocation().Y,
 | 
				
			||||||
						GetActorLocation().Z - GetCapsuleComponent()->GetScaledCapsuleHalfHeight());
 | 
											GetActorLocation().Z - GetCapsuleComponent()->GetScaledCapsuleHalfHeight());
 | 
				
			||||||
		FVector ActorForward = UKismetMathLibrary::GetForwardVector(GetActorRotation());
 | 
							FVector ActorForward = UKismetMathLibrary::GetForwardVector(GetActorRotation());
 | 
				
			||||||
		DrawDebugDirectionalArrow(GetWorld(),
 | 
					 | 
				
			||||||
			StartPos, StartPos + (ActorForward * ((LateralSpeed / GetCharacterMovement()->MaxWalkSpeed) * 100.0f)),
 | 
					 | 
				
			||||||
			10.0f, FColor::Blue, false, -1.0f, 0, 2.0f);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Draw arrow showing velocity 
 | 
				
			||||||
 | 
							DrawDebugDirectionalArrow(GetWorld(),
 | 
				
			||||||
 | 
								StartPos, StartPos + (VelocityDir * ((GetVelocity().Size() / GetCharacterMovement()->MaxWalkSpeed) * 100.0f)),
 | 
				
			||||||
 | 
								10.0f, FColor::Yellow, false, -1.0f, 0, 2.0f);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							// Draw arrow showing lateral velocity
 | 
				
			||||||
 | 
							StartPos.Z += 1; // avoid z-fighting
 | 
				
			||||||
 | 
							DrawDebugDirectionalArrow(GetWorld(),
 | 
				
			||||||
 | 
								StartPos, StartPos + (LateralVelocityDir * ((LateralSpeed / GetCharacterMovement()->MaxWalkSpeed) * 100.0f)),
 | 
				
			||||||
 | 
								10.0f, FColor::Orange, false, -1.0f, 0, 2.0f);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							// draw arrow showing what direction the player is inputting (WASD or right thumbstick) in the world relative to the camera 
 | 
				
			||||||
		FVector CurrInputDirection = GetInputAsWorldDirection();
 | 
							FVector CurrInputDirection = GetInputAsWorldDirection();
 | 
				
			||||||
		CurrInputDirection.Normalize();
 | 
							CurrInputDirection.Normalize();
 | 
				
			||||||
 | 
							StartPos.Z += 1; // avoid z-fighting
 | 
				
			||||||
		DrawDebugDirectionalArrow(GetWorld(), StartPos, StartPos + (CurrInputDirection * 100.0f),
 | 
							DrawDebugDirectionalArrow(GetWorld(), StartPos, StartPos + (CurrInputDirection * 100.0f),
 | 
				
			||||||
		10.0f, FColor::Purple, false, -1.0f, 0, 2.0f);
 | 
							10.0f, FColor::Purple, false, -1.0f, 0, 2.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Draw arrow showing where character is facing
 | 
				
			||||||
 | 
							StartPos.Z += 1; // avoid z-fighting
 | 
				
			||||||
 | 
							DrawDebugDirectionalArrow(GetWorld(),
 | 
				
			||||||
 | 
								StartPos, StartPos + (ActorForward * 100.0f),
 | 
				
			||||||
 | 
								10.0f, FColor::Blue, false, -1.0f, 0, 2.0f);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		FString DebugMsg = FString::Printf(TEXT("MaxWalkSpeed: %f"), GetCharacterMovement()->MaxWalkSpeed);
 | 
							FString DebugMsg = FString::Printf(TEXT("MaxWalkSpeed: %f"), GetCharacterMovement()->MaxWalkSpeed);
 | 
				
			||||||
		GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Magenta, DebugMsg);
 | 
							GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Magenta, DebugMsg);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		DebugMsg = FString::Printf(TEXT("LateralSpeed: %f"), LateralSpeed);
 | 
							DebugMsg = FString::Printf(TEXT("LateralSpeed: %f"), LateralSpeed);
 | 
				
			||||||
		GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Magenta, DebugMsg);
 | 
							GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Magenta, DebugMsg);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		DebugMsg = FString::Printf(TEXT("RotationRate: %s"), *GetCharacterMovement()->RotationRate.ToString());
 | 
							DebugMsg = FString::Printf(TEXT("RotationRate: %s"), *GetCharacterMovement()->RotationRate.ToString());
 | 
				
			||||||
		GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Magenta, DebugMsg);
 | 
							GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Magenta, DebugMsg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							bool InputThresholdIsMet = CurrInputDirection.Size2D() >= InputThreshold;
 | 
				
			||||||
 | 
							DebugMsg = FString::Printf(TEXT("InputThresholdIsMet: %hs"), InputThresholdIsMet ? "true" : "false");
 | 
				
			||||||
 | 
							GEngine->AddOnScreenDebugMessage(-1, 0.0f, FColor::Magenta, DebugMsg);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		if(ShowCharacterTrajectory)
 | 
							if(ShowCharacterTrajectory)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if(GetWorld()->TimeSeconds - LastSavedPosTime >= TrajectoryPeriod)
 | 
								if(GetWorld()->TimeSeconds - LastSavedPosTime >= TrajectoryPeriod)
 | 
				
			||||||
@ -260,6 +284,6 @@ void ASNGCharacterBase::SetupPlayerInputComponent(UInputComponent* PlayerInputCo
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// actions
 | 
						// actions
 | 
				
			||||||
	PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ASNGCharacterBase::StartJump);
 | 
						PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ASNGCharacterBase::StartJump);
 | 
				
			||||||
	PlayerInputComponent->BindAction("Jump", IE_Released, this, &ASNGCharacterBase::StopJumping);
 | 
						//PlayerInputComponent->BindAction("Jump", IE_Released, this, &ASNGCharacterBase::StopJumping);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "Components/SNGCharacterMovementComponent.h"
 | 
					#include "Components/SNGCharacterMovementComponent.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "Characters/SNGCharacterBase.h"
 | 
				
			||||||
#include "GameFramework/Character.h"
 | 
					#include "GameFramework/Character.h"
 | 
				
			||||||
#include "Kismet/KismetMathLibrary.h"
 | 
					#include "Kismet/KismetMathLibrary.h"
 | 
				
			||||||
#include "PhysicsEngine/PhysicsSettings.h"
 | 
					#include "PhysicsEngine/PhysicsSettings.h"
 | 
				
			||||||
@ -33,6 +34,8 @@ USNGCharacterMovementComponent::USNGCharacterMovementComponent()
 | 
				
			|||||||
	// jump
 | 
						// jump
 | 
				
			||||||
	MaxJumpHeight = 250.0f;
 | 
						MaxJumpHeight = 250.0f;
 | 
				
			||||||
	DesiredJumpDuration = 0.75f;
 | 
						DesiredJumpDuration = 0.75f;
 | 
				
			||||||
 | 
						DefaultJumpLateralVelocity = DefaultMaxWalkSpeed;
 | 
				
			||||||
 | 
						LateralVelocityScaling = FVector2D(1.0f, 1.0f);
 | 
				
			||||||
	ComputeGravityScaleAndJumpZVelocity();
 | 
						ComputeGravityScaleAndJumpZVelocity();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// dash
 | 
						// dash
 | 
				
			||||||
@ -78,16 +81,16 @@ void USNGCharacterMovementComponent::RestoreMovementDefaults()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void USNGCharacterMovementComponent::Dash()
 | 
					void USNGCharacterMovementComponent::Dash()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	FLaunchParameters LaunchParams;
 | 
						FLaunchParameters DashParams;
 | 
				
			||||||
	LaunchParams.bOverrideX = true;
 | 
						DashParams.bOverrideLateralVelocityClamping = true;
 | 
				
			||||||
	LaunchParams.bOverrideY = true;
 | 
						DashParams.bOverrideX = true;
 | 
				
			||||||
	LaunchParams.bOverrideZ = true;
 | 
						DashParams.bOverrideY = true;
 | 
				
			||||||
	LaunchParams.bOverrideMovementMode = false;
 | 
						DashParams.bOverrideZ = true;
 | 
				
			||||||
	LaunchParams.GroundFriction = DashGroundFriction;
 | 
						DashParams.bOverrideMovementMode = false;
 | 
				
			||||||
	LaunchParams.GravityScale = DashGravityScale;
 | 
						DashParams.GroundFriction = DashGroundFriction;
 | 
				
			||||||
	LaunchParams.FloatTime = DashFloatTime;
 | 
						DashParams.GravityScale = DashGravityScale;
 | 
				
			||||||
	LaunchParams.SlideTime = DashSlideTime;
 | 
						DashParams.FloatTime = DashFloatTime;
 | 
				
			||||||
	
 | 
						DashParams.SlideTime = DashSlideTime;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// sets gravity and friction targets which will start interpolating after float time and slide time elapse respectively
 | 
						// sets gravity and friction targets which will start interpolating after float time and slide time elapse respectively
 | 
				
			||||||
	TargetGravityScale = DefaultGravityScale;
 | 
						TargetGravityScale = DefaultGravityScale;
 | 
				
			||||||
@ -95,12 +98,12 @@ void USNGCharacterMovementComponent::Dash()
 | 
				
			|||||||
	GravityScaleInterpSpeed = DashGravityToDefaultSpeed;
 | 
						GravityScaleInterpSpeed = DashGravityToDefaultSpeed;
 | 
				
			||||||
	GroundFrictionInterpSpeed = DashGroundFrictionToDefaultSpeed;
 | 
						GroundFrictionInterpSpeed = DashGroundFrictionToDefaultSpeed;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	FRotator CharacterRot = FRotator(0.0f, GetCharacterOwner()->GetActorRotation().Yaw, 0.0f);
 | 
						FRotator CharacterRot = FRotator(0.0f, CharacterOwner->GetActorRotation().Yaw, 0.0f);
 | 
				
			||||||
	FVector LaunchDir = FVector(UKismetMathLibrary::GetForwardVector(CharacterRot));
 | 
						FVector LaunchDir = FVector(UKismetMathLibrary::GetForwardVector(CharacterRot));
 | 
				
			||||||
	LaunchDir.Normalize();
 | 
						LaunchDir.Normalize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LaunchParams.Velocity = LaunchDir * DashVelocity;
 | 
						DashParams.Velocity = LaunchDir * DashVelocity;
 | 
				
			||||||
	LaunchCharacter(LaunchParams);
 | 
						LaunchCharacter(DashParams);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if WITH_EDITOR
 | 
					#if WITH_EDITOR
 | 
				
			||||||
@ -136,7 +139,6 @@ void USNGCharacterMovementComponent::LaunchCharacter(const FLaunchParameters Lau
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	Velocity *= LaunchParams.VelocityScale;
 | 
						Velocity *= LaunchParams.VelocityScale;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// 
 | 
					 | 
				
			||||||
	if(LaunchParams.bOverrideX)
 | 
						if(LaunchParams.bOverrideX)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		Velocity.X = LaunchParams.Velocity.X;
 | 
							Velocity.X = LaunchParams.Velocity.X;
 | 
				
			||||||
@ -164,6 +166,14 @@ void USNGCharacterMovementComponent::LaunchCharacter(const FLaunchParameters Lau
 | 
				
			|||||||
		Velocity.Z += LaunchParams.Velocity.Z;
 | 
							Velocity.Z += LaunchParams.Velocity.Z;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(!LaunchParams.bOverrideLateralVelocityClamping)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							// clamp lateral velocity to max walk speed
 | 
				
			||||||
 | 
							FVector LateralVelocity = FVector(Velocity.X, Velocity.Y, 0.0f);
 | 
				
			||||||
 | 
							LateralVelocity = LateralVelocity.GetClampedToMaxSize(DefaultMaxWalkSpeed);
 | 
				
			||||||
 | 
							Velocity = FVector(LateralVelocity.X, LateralVelocity.Y, Velocity.Z);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	GroundFriction = LaunchParams.bUseDefaultGroundFriction ? DefaultGroundFriction : LaunchParams.GroundFriction;
 | 
						GroundFriction = LaunchParams.bUseDefaultGroundFriction ? DefaultGroundFriction : LaunchParams.GroundFriction;
 | 
				
			||||||
	GravityScale = LaunchParams.bUseDefaultGravityScale ? DefaultGravityScale : LaunchParams.GravityScale;
 | 
						GravityScale = LaunchParams.bUseDefaultGravityScale ? DefaultGravityScale : LaunchParams.GravityScale;
 | 
				
			||||||
	FloatTime = LaunchParams.FloatTime;
 | 
						FloatTime = LaunchParams.FloatTime;
 | 
				
			||||||
@ -192,13 +202,27 @@ bool USNGCharacterMovementComponent::DoJump(bool bReplayingMoves)
 | 
				
			|||||||
		// Don't jump if we can't move up/down.
 | 
							// Don't jump if we can't move up/down.
 | 
				
			||||||
		if (!bConstrainToPlane || FMath::Abs(PlaneConstraintNormal.Z) != 1.f)
 | 
							if (!bConstrainToPlane || FMath::Abs(PlaneConstraintNormal.Z) != 1.f)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 | 
								ASNGCharacterBase* CharacterOwnerAsSNGChar = Cast<ASNGCharacterBase>(CharacterOwner);
 | 
				
			||||||
 | 
								if(CharacterOwnerAsSNGChar)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
				FLaunchParameters JumpParams;
 | 
									FLaunchParameters JumpParams;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									FVector WorldInputDir = CharacterOwnerAsSNGChar->GetInputAsWorldDirection();
 | 
				
			||||||
 | 
									if(WorldInputDir.Size2D() >= CharacterOwnerAsSNGChar->GetInputThreshold())
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										FVector JumpLateralVelocity = WorldInputDir * DefaultJumpLateralVelocity;
 | 
				
			||||||
 | 
										JumpParams.Velocity.X = JumpLateralVelocity.X;
 | 
				
			||||||
 | 
										JumpParams.Velocity.Y = JumpLateralVelocity.Y;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									
 | 
				
			||||||
				JumpParams.Velocity.Z = DefaultJumpZVelocity;
 | 
									JumpParams.Velocity.Z = DefaultJumpZVelocity;
 | 
				
			||||||
 | 
									JumpParams.bOverrideLateralVelocityClamping = false;
 | 
				
			||||||
				JumpParams.bOverrideX = false;
 | 
									JumpParams.bOverrideX = false;
 | 
				
			||||||
				JumpParams.bOverrideY = false;
 | 
									JumpParams.bOverrideY = false;
 | 
				
			||||||
				JumpParams.bOverrideZ = true;
 | 
									JumpParams.bOverrideZ = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									JumpParams.VelocityScale = FVector(LateralVelocityScaling, 1.0f);
 | 
				
			||||||
 | 
									
 | 
				
			||||||
				JumpParams.bUseDefaultGroundFriction = true;
 | 
									JumpParams.bUseDefaultGroundFriction = true;
 | 
				
			||||||
				JumpParams.bUseDefaultGravityScale = true;
 | 
									JumpParams.bUseDefaultGravityScale = true;
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
@ -208,6 +232,12 @@ bool USNGCharacterMovementComponent::DoJump(bool bReplayingMoves)
 | 
				
			|||||||
				LaunchCharacter(JumpParams);
 | 
									LaunchCharacter(JumpParams);
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									UE_LOG(LogTemp, Error, TEXT("SNGCharacterMovementComponent :: DoJump :: Could not cast CharacterOwner to ASNGCharacterBase"));
 | 
				
			||||||
 | 
									return false;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
 | 
				
			|||||||
@ -18,6 +18,10 @@ public:
 | 
				
			|||||||
	// Sets default values for this character's properties
 | 
						// Sets default values for this character's properties
 | 
				
			||||||
	ASNGCharacterBase(const FObjectInitializer& ObjectInitializer);
 | 
						ASNGCharacterBase(const FObjectInitializer& ObjectInitializer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						FVector GetInputAsWorldDirection();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						FORCEINLINE float GetInputThreshold() { return InputThreshold; } 
 | 
				
			||||||
 | 
						
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
 | 
						UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
 | 
				
			||||||
	UCameraComponent* CameraComponent;
 | 
						UCameraComponent* CameraComponent;
 | 
				
			||||||
@ -28,6 +32,10 @@ protected:
 | 
				
			|||||||
	UPROPERTY(BlueprintReadOnly)
 | 
						UPROPERTY(BlueprintReadOnly)
 | 
				
			||||||
	FVector2D InputDirection;
 | 
						FVector2D InputDirection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** Magnitude InputDirection needs to meet for the input to be considered "non-zero" */
 | 
				
			||||||
 | 
						UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Input")
 | 
				
			||||||
 | 
						float InputThreshold;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Animations")
 | 
						UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Animations")
 | 
				
			||||||
	UAnimMontage* JumpNeutralMontage;
 | 
						UAnimMontage* JumpNeutralMontage;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@ -73,8 +81,6 @@ protected:
 | 
				
			|||||||
	// Called when the game starts or when spawned
 | 
						// Called when the game starts or when spawned
 | 
				
			||||||
	virtual void BeginPlay() override;
 | 
						virtual void BeginPlay() override;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	FVector GetInputAsWorldDirection();
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
public:	
 | 
					public:	
 | 
				
			||||||
	// Called every frame
 | 
						// Called every frame
 | 
				
			||||||
	virtual void Tick(float DeltaTime) override;
 | 
						virtual void Tick(float DeltaTime) override;
 | 
				
			||||||
 | 
				
			|||||||
@ -22,6 +22,10 @@ struct FLaunchParameters
 | 
				
			|||||||
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
 | 
						UPROPERTY(EditAnywhere, BlueprintReadWrite)
 | 
				
			||||||
	FVector VelocityScale;
 | 
						FVector VelocityScale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** If true, lateral velocity will NOT be clamped to max walk speed after performing all other velocity update operations */ 
 | 
				
			||||||
 | 
						UPROPERTY(EditAnywhere, BlueprintReadWrite)
 | 
				
			||||||
 | 
						bool bOverrideLateralVelocityClamping;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 *	Should the X component of character's velocity be overriden with Velocity parameter or added?
 | 
						 *	Should the X component of character's velocity be overriden with Velocity parameter or added?
 | 
				
			||||||
	 *	Default is false which means Velocity X component will be added to current character's velocity
 | 
						 *	Default is false which means Velocity X component will be added to current character's velocity
 | 
				
			||||||
@ -84,6 +88,7 @@ struct FLaunchParameters
 | 
				
			|||||||
	FLaunchParameters()
 | 
						FLaunchParameters()
 | 
				
			||||||
	: Velocity(FVector::ZeroVector)
 | 
						: Velocity(FVector::ZeroVector)
 | 
				
			||||||
	, VelocityScale(FVector::OneVector)
 | 
						, VelocityScale(FVector::OneVector)
 | 
				
			||||||
 | 
						, bOverrideLateralVelocityClamping(false)
 | 
				
			||||||
	, bOverrideX(false)
 | 
						, bOverrideX(false)
 | 
				
			||||||
	, bOverrideY(false)
 | 
						, bOverrideY(false)
 | 
				
			||||||
	, bOverrideZ(false)
 | 
						, bOverrideZ(false)
 | 
				
			||||||
@ -227,10 +232,6 @@ protected:
 | 
				
			|||||||
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="SNG Character Movement|Defaults|Air", meta=(ClampMin="0", UIMin="0"))
 | 
						UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="SNG Character Movement|Defaults|Air", meta=(ClampMin="0", UIMin="0"))
 | 
				
			||||||
	float DefaultGravityScale;
 | 
						float DefaultGravityScale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** How much to dampen lateral velocities at the start of a jump */
 | 
					 | 
				
			||||||
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="SNG Character Movement|Defaults|Air", meta=(ClampMin="0", UIMin="0"))
 | 
					 | 
				
			||||||
	float LateralVelocityDampening;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/** Gravity Scale we want character to interpolate to. Interpolated based on GravityScaleInterpSpeed. */
 | 
						/** Gravity Scale we want character to interpolate to. Interpolated based on GravityScaleInterpSpeed. */
 | 
				
			||||||
	UPROPERTY(BlueprintReadWrite)
 | 
						UPROPERTY(BlueprintReadWrite)
 | 
				
			||||||
	float TargetGravityScale;
 | 
						float TargetGravityScale;
 | 
				
			||||||
@ -260,7 +261,7 @@ protected:
 | 
				
			|||||||
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="SNG Character Movement|Jump", meta=(ClampMin="0", UIMin="0"))
 | 
						UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="SNG Character Movement|Jump", meta=(ClampMin="0", UIMin="0"))
 | 
				
			||||||
	float DesiredJumpDuration;
 | 
						float DesiredJumpDuration;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/** Force to continuously apply to character when they are holding the jump button */
 | 
						/** Z velocity set on the character when they are press the jump button */
 | 
				
			||||||
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="SNG Character Movement|Jump", meta=(ClampMin="0", UIMin="0"))
 | 
						UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="SNG Character Movement|Jump", meta=(ClampMin="0", UIMin="0"))
 | 
				
			||||||
	float DefaultJumpZVelocity;
 | 
						float DefaultJumpZVelocity;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@ -272,6 +273,18 @@ protected:
 | 
				
			|||||||
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="SNG Character Movement|Jump", meta=(ClampMin="0", UIMin="0"))
 | 
						UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="SNG Character Movement|Jump", meta=(ClampMin="0", UIMin="0"))
 | 
				
			||||||
	float MaxJumpTime;
 | 
						float MaxJumpTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 *	Lateral velocity to set when the player initiates jump and is holding a direction.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 *	This value is multiplied by the world direction the player is inputting.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="SNG Character Movement|Jump", meta=(ClampMin="0", UIMin="0"))
 | 
				
			||||||
 | 
						float DefaultJumpLateralVelocity;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						/** How much to scale lateral velocity by when a jump is initiated */
 | 
				
			||||||
 | 
						UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="SNG Character Movement|Jump", meta=(ClampMin="0", UIMin="0"))
 | 
				
			||||||
 | 
						FVector2D LateralVelocityScaling;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	void ComputeGravityScaleAndJumpZVelocity();
 | 
						void ComputeGravityScaleAndJumpZVelocity();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	virtual bool DoJump(bool bReplayingMoves) override;
 | 
						virtual bool DoJump(bool bReplayingMoves) override;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user