mirror of
https://github.com/fortressforever/enthusiastic-hat-club.git
synced 2024-11-21 20:01:06 +00:00
wireup inputs and add jumping
This commit is contained in:
parent
cc2f669b3a
commit
2a4092c97a
6 changed files with 87 additions and 19 deletions
|
@ -31,5 +31,21 @@ void AFFCharacter::BeginPlay()
|
|||
void AFFCharacter::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
}
|
||||
|
||||
}
|
||||
// movement section
|
||||
// NOTE: non-axis movement is triggered from controller which checks 0 value locks
|
||||
// its kind of a round-about way to handle input:
|
||||
// 1 - controller bindings
|
||||
// 2 - character adds movement input value
|
||||
// 3 - character movement triggered
|
||||
// mouse skips right to adding input value
|
||||
void AFFCharacter::MovementForwardBack(float Value)
|
||||
{
|
||||
AddMovementInput(GetActorForwardVector(), Value);
|
||||
}
|
||||
|
||||
void AFFCharacter::MovementStrafe(float Value)
|
||||
{
|
||||
AddMovementInput(GetActorRightVector(), Value);
|
||||
}
|
||||
|
|
|
@ -33,4 +33,8 @@ public:
|
|||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
FORCEINLINE class UCameraComponent* GetFirstPersonCameraComponent() const { return CameraComponent; }
|
||||
|
||||
// Movement commands from input
|
||||
void MovementStrafe(float Value);
|
||||
void MovementForwardBack(float Value);
|
||||
};
|
||||
|
|
|
@ -13,17 +13,39 @@ UFFCharacterMovement::UFFCharacterMovement(const class FObjectInitializer& Objec
|
|||
// q2 style double jumps
|
||||
// rampslides and sharks
|
||||
// would rather simplify and just make the movement fast and crisp to start with,
|
||||
// which surprisingly the default networked movement can do OK at
|
||||
// which surprisingly the default networked movement can do OK at .
|
||||
// if someone was so inclined to do so, this class would be the place to do it as it can handle
|
||||
// the frame by frame movement calculations and pmove
|
||||
|
||||
MaxWalkSpeed = 1105.0f;
|
||||
AirControl = 0.65f;
|
||||
GroundFriction = 11.0f;
|
||||
BrakingFriction = 12.0f;
|
||||
MaxWalkSpeed = 1000.0f;
|
||||
AirControl = 0.75f;
|
||||
GroundFriction = 4.0f;
|
||||
BrakingFriction = 10.0f;
|
||||
BrakingFrictionFactor = 3;
|
||||
GravityScale = 1.0f;
|
||||
JumpZVelocity = 350.0f;
|
||||
BrakingDecelerationFalling = 1.0f;
|
||||
|
||||
JumpZVelocity = 800.0f;
|
||||
|
||||
MaxAcceleration = 3500.0f;
|
||||
Mass = 110.0f;
|
||||
// todo: non-accel based strafe movement etc
|
||||
MaxAcceleration = 6500.0f;
|
||||
|
||||
// verdict is out on this one
|
||||
NetworkSmoothingMode = ENetworkSmoothingMode::Exponential;
|
||||
}
|
||||
|
||||
bool UFFCharacterMovement::DoJump(bool bReplayingMoves)
|
||||
{
|
||||
if (CharacterOwner && CharacterOwner->CanJump())
|
||||
{
|
||||
// Don't jump if we can't move up/down.
|
||||
if (!bConstrainToPlane || FMath::Abs(PlaneConstraintNormal.Z) != 1.f)
|
||||
{
|
||||
Velocity.Z = JumpZVelocity;
|
||||
SetMovementMode(MOVE_Falling);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
|
@ -12,4 +12,7 @@ UCLASS()
|
|||
class FF_API UFFCharacterMovement : public UCharacterMovementComponent
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
public:
|
||||
bool DoJump(bool bReplayingMoves);
|
||||
};
|
||||
|
|
|
@ -11,8 +11,8 @@ void AFFPlayerController::SetupInputComponent()
|
|||
Super::SetupInputComponent();
|
||||
|
||||
// TODO: the base ACharacter jump handling kinda stinks
|
||||
//InputComponent->BindAction("Jump", IE_Pressed, this, &AFFPlayerController::InputJump);
|
||||
//InputComponent->BindAction("Jump", IE_Released, this, &AFFPlayerController::InputStopJumping);
|
||||
InputComponent->BindAction("Jump", IE_Pressed, this, &AFFPlayerController::JumpPressed);
|
||||
InputComponent->BindAction("Jump", IE_Released, this, &AFFPlayerController::JumpReleased);
|
||||
InputComponent->BindAxis("Forward", this, &AFFPlayerController::Forward);
|
||||
InputComponent->BindAxis("Strafe", this, &AFFPlayerController::Strafe);
|
||||
InputComponent->BindAxis("LookX", this, &AFFPlayerController::LookX);
|
||||
|
@ -21,34 +21,54 @@ void AFFPlayerController::SetupInputComponent()
|
|||
MouseSensitivityRate = 150.0f;
|
||||
}
|
||||
|
||||
// bind axis has nonconst :-(
|
||||
|
||||
// ReSharper disable once CppMemberFunctionMayBeConst
|
||||
void AFFPlayerController::Forward(float Value)
|
||||
{
|
||||
if (Value != 0.0f)
|
||||
{
|
||||
// add movement in that direction
|
||||
//AddMovementInput(GetActorForwardVector(), Value);
|
||||
FFCharacter->MovementForwardBack(Value);
|
||||
}
|
||||
}
|
||||
|
||||
// ReSharper disable once CppMemberFunctionMayBeConst
|
||||
void AFFPlayerController::Strafe(float Value)
|
||||
{
|
||||
if (Value != 0.0f)
|
||||
{
|
||||
// add movement in that direction
|
||||
//AddMovementInput(GetActorRightVector(), Value);
|
||||
FFCharacter->MovementStrafe(Value);
|
||||
}
|
||||
}
|
||||
|
||||
void AFFPlayerController::LookX(float Rate)
|
||||
{
|
||||
// calculate delta for this frame from the rate information
|
||||
//AddControllerYawInput(Rate * MouseSensitivityRate * GetWorld()->GetDeltaSeconds());
|
||||
AddYawInput(Rate * MouseSensitivityRate * GetWorld()->GetDeltaSeconds());
|
||||
}
|
||||
|
||||
void AFFPlayerController::LookY(float Rate)
|
||||
{
|
||||
// calculate delta for this frame from the rate information
|
||||
//AddControllerPitchInput(Rate * MouseSensitivityRate * GetWorld()->GetDeltaSeconds());
|
||||
AddPitchInput(Rate * MouseSensitivityRate * GetWorld()->GetDeltaSeconds());
|
||||
}
|
||||
|
||||
void AFFPlayerController::JumpPressed()
|
||||
{
|
||||
if (FFCharacter != NULL && !IsMoveInputIgnored())
|
||||
{
|
||||
//FFCharacter->bPressedJump = true;
|
||||
FFCharacter->Jump();
|
||||
}
|
||||
}
|
||||
|
||||
void AFFPlayerController::JumpReleased()
|
||||
{
|
||||
if (FFCharacter)
|
||||
{
|
||||
//FFCharacter->bPressedJump = false;
|
||||
FFCharacter->StopJumping();
|
||||
}
|
||||
}
|
||||
|
||||
void AFFPlayerController::SetPawn(APawn* NewPawn)
|
||||
|
@ -75,6 +95,7 @@ void AFFPlayerController::SetPawn(APawn* NewPawn)
|
|||
|
||||
AFFCharacter* AFFPlayerController::GetFFCharacter()
|
||||
{
|
||||
// TODO:
|
||||
return nullptr;
|
||||
// for BPs
|
||||
return FFCharacter;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ private:
|
|||
void Strafe(float Val);
|
||||
void LookX(float Rate);
|
||||
void LookY(float Rate);
|
||||
void JumpPressed();
|
||||
void JumpReleased();
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintReadOnly, GlobalConfig, Category = Camera)
|
||||
|
|
Loading…
Reference in a new issue