feat: add all controls and dodge logic
Added dodge mechanic with temporary values for testing. Dodge properties (dodge force., cooldown) are subject to change.
This commit is contained in:
parent
b97d63bad5
commit
d95a23f2e7
Binary file not shown.
Binary file not shown.
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Aim.uasset
Normal file
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Aim.uasset
Normal file
Binary file not shown.
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Crouch.uasset
Normal file
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Crouch.uasset
Normal file
Binary file not shown.
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Dodge.uasset
Normal file
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Dodge.uasset
Normal file
Binary file not shown.
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Jump.uasset
Normal file
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Jump.uasset
Normal file
Binary file not shown.
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_MeleAttack.uasset
Normal file
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_MeleAttack.uasset
Normal file
Binary file not shown.
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Reload.uasset
Normal file
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Reload.uasset
Normal file
Binary file not shown.
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Shoot.uasset
Normal file
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Shoot.uasset
Normal file
Binary file not shown.
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Sprint.uasset
Normal file
BIN
Content/Blueprints/Player/Inputs/Inputs/AI_Sprint.uasset
Normal file
Binary file not shown.
|
|
@ -5,6 +5,7 @@
|
|||
#include "EnhancedInputComponent.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
|
||||
AExoPlayerController::AExoPlayerController()
|
||||
{
|
||||
|
|
@ -42,6 +43,8 @@ void AExoPlayerController::SetupInputComponent()
|
|||
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AExoPlayerController::Move);
|
||||
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AExoPlayerController::Look);
|
||||
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Triggered, this, &AExoPlayerController::Interact);
|
||||
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerJump);
|
||||
EnhancedInputComponent->BindAction(DodgeAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerDodge);
|
||||
}
|
||||
|
||||
void AExoPlayerController::Move(const FInputActionValue& InputActionValue)
|
||||
|
|
@ -74,3 +77,69 @@ void AExoPlayerController::Interact(const FInputActionValue& InputActionValue)
|
|||
if (InteractionComponent->InteractedActor)
|
||||
IInteractable::Execute_Interact(InteractionComponent->InteractedActor);
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerJump()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerDodge()
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("Player Dodge"));
|
||||
|
||||
if (PlayerCharacter->GetCharacterMovement()->IsFalling()) return;
|
||||
|
||||
if (!CanDodge) return;
|
||||
|
||||
CanDodge = false;
|
||||
|
||||
FVector DodgeDirection = PlayerCharacter->GetVelocity().GetSafeNormal();
|
||||
DodgeDirection.Z = 0.f;
|
||||
|
||||
if (DodgeDirection.IsNearlyZero())
|
||||
DodgeDirection = PlayerCharacter->GetActorForwardVector();
|
||||
|
||||
PlayerCharacter->LaunchCharacter(DodgeDirection * DodgeForce, true, true);
|
||||
|
||||
GetWorldTimerManager().SetTimer(DodgeCooldownTimer, this, &AExoPlayerController::ResetDodge, DodgeCooldown, false);
|
||||
}
|
||||
|
||||
void AExoPlayerController::ResetDodge()
|
||||
{
|
||||
CanDodge = true;
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerCrouch()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerSprint()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerShoot()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerAim()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerMeleAttack()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerChangeWeapon()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AExoPlayerController::PlayerReload()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,14 +26,46 @@ public:
|
|||
protected:
|
||||
virtual void SetupInputComponent() override;
|
||||
|
||||
// Moja propozycja sterowania po prawej [Hubert]
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void Move(const FInputActionValue& InputActionValue);
|
||||
void Move(const FInputActionValue& InputActionValue); //WSAD
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void Look(const FInputActionValue& InputActionValue);
|
||||
void Look(const FInputActionValue& InputActionValue); // MouseXY
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void Interact(const FInputActionValue& InputActionValue);
|
||||
void Interact(const FInputActionValue& InputActionValue); // E
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerJump(); // Space
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerDodge(); // LShift(Pressed)
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void ResetDodge();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerCrouch(); // LCtrl\C\X
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerSprint(); // LShift(Hold)
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerShoot(); // LPM
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerAim(); // PPM
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerMeleAttack(); // V
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerChangeWeapon(); // 1\2\MouseScroll
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
void PlayerReload(); // R
|
||||
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
|
|
@ -42,11 +74,50 @@ protected:
|
|||
UPROPERTY(EditAnywhere, Category= "Input")
|
||||
TObjectPtr<UInputAction> MoveAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> InteractAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> LookAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> InteractAction;
|
||||
TObjectPtr<UInputAction> JumpAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> SprintAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> CrouchAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> DodgeAction;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Dodge Properties")
|
||||
FTimerHandle DodgeCooldownTimer;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
||||
float DodgeForce = 5000.f; // Move to player if future for better modification
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
||||
float DodgeCooldown = 2.f; // Move to player too.
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
||||
bool CanDodge = true;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> ShootAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> ReloadAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> AimAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> MeleAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Input")
|
||||
TObjectPtr<UInputAction> ChangeWeaponAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character")
|
||||
TObjectPtr<ACharacter> PlayerCharacter;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user