fix
This commit is contained in:
Generated
+15
@@ -0,0 +1,15 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/.idea.NERGUS.iml
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/projectSettingsUpdater.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+15
@@ -0,0 +1,15 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/.idea.NERGUS.iml
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/projectSettingsUpdater.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"components": [
|
||||
"Component.Unreal.Debugger",
|
||||
"Component.Unreal.Ide",
|
||||
"Microsoft.Net.Component.4.6.2.TargetingPack",
|
||||
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL",
|
||||
"Microsoft.VisualStudio.Component.VC.14.38.17.8.x86.x64",
|
||||
"Microsoft.VisualStudio.Component.VC.Llvm.Clang",
|
||||
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
|
||||
"Microsoft.VisualStudio.Component.Windows11SDK.22621",
|
||||
"Microsoft.VisualStudio.Workload.CoreEditor",
|
||||
"Microsoft.VisualStudio.Workload.ManagedDesktop",
|
||||
"Microsoft.VisualStudio.Workload.NativeDesktop",
|
||||
"Microsoft.VisualStudio.Workload.NativeGame"
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
LFS
BIN
Binary file not shown.
LFS
BIN
Binary file not shown.
LFS
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -9,6 +9,8 @@
|
||||
#include "InputActionValue.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "NERGUS.h"
|
||||
#include "Components/SphereComponent.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
|
||||
ANERGUSCharacter::ANERGUSCharacter()
|
||||
{
|
||||
@@ -18,14 +20,30 @@ ANERGUSCharacter::ANERGUSCharacter()
|
||||
// Create the first person mesh that will be viewed only by this character's owner
|
||||
FirstPersonMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("First Person Mesh"));
|
||||
|
||||
FirstPersonMesh->SetupAttachment(GetMesh());
|
||||
|
||||
|
||||
// Create the SpringArm Component
|
||||
FirstPersonSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("First Person Spring Arm"));
|
||||
FirstPersonSpringArm->SetupAttachment(RootComponent);
|
||||
|
||||
// Create the ArmSwaySphere
|
||||
SwayComponent = CreateDefaultSubobject<USphereComponent>(TEXT("ArmSwaySphere"));
|
||||
SwayComponent->SetupAttachment(FirstPersonSpringArm);
|
||||
|
||||
// FirstPersonMesh->SetupAttachment(GetMesh());
|
||||
FirstPersonMesh->SetupAttachment(SwayComponent);
|
||||
FirstPersonMesh->SetOnlyOwnerSee(true);
|
||||
FirstPersonMesh->FirstPersonPrimitiveType = EFirstPersonPrimitiveType::FirstPerson;
|
||||
FirstPersonMesh->SetCollisionProfileName(FName("NoCollision"));
|
||||
|
||||
// Create the Arm Mesh
|
||||
FirstPersonArmMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("First person arm"));
|
||||
FirstPersonArmMesh->SetupAttachment(SwayComponent);
|
||||
|
||||
// Create the Camera Component
|
||||
FirstPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("First Person Camera"));
|
||||
FirstPersonCameraComponent->SetupAttachment(FirstPersonMesh, FName("head"));
|
||||
//FirstPersonCameraComponent->SetupAttachment(FirstPersonMesh, FName("head"));
|
||||
FirstPersonCameraComponent->SetupAttachment(FirstPersonArmMesh);
|
||||
FirstPersonCameraComponent->SetRelativeLocationAndRotation(FVector(-2.8f, 5.89f, 0.0f), FRotator(0.0f, 90.0f, -90.0f));
|
||||
FirstPersonCameraComponent->bUsePawnControlRotation = true;
|
||||
FirstPersonCameraComponent->bEnableFirstPersonFieldOfView = true;
|
||||
@@ -33,6 +51,11 @@ ANERGUSCharacter::ANERGUSCharacter()
|
||||
FirstPersonCameraComponent->FirstPersonFieldOfView = 70.0f;
|
||||
FirstPersonCameraComponent->FirstPersonScale = 0.6f;
|
||||
|
||||
|
||||
|
||||
// FirstPersoSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("First Person SpringArm"));
|
||||
// FirstPersoSpringArm->SetupAttachment(RootComponent);
|
||||
|
||||
// configure the character comps
|
||||
GetMesh()->SetOwnerNoSee(true);
|
||||
GetMesh()->FirstPersonPrimitiveType = EFirstPersonPrimitiveType::WorldSpaceRepresentation;
|
||||
@@ -40,8 +63,18 @@ ANERGUSCharacter::ANERGUSCharacter()
|
||||
GetCapsuleComponent()->SetCapsuleSize(34.0f, 96.0f);
|
||||
|
||||
// Configure character movement
|
||||
GetCharacterMovement()->BrakingDecelerationFalling = 1500.0f;
|
||||
GetCharacterMovement()->AirControl = 0.5f;
|
||||
//GetCharacterMovement()->BrakingDecelerationFalling = 1500.0f;
|
||||
//GetCharacterMovement()->AirControl = 0.5f;
|
||||
}
|
||||
|
||||
void ANERGUSCharacter::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
if (IsLocallyControlled())
|
||||
{
|
||||
SwayFunction(DeltaTime);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ANERGUSCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
@@ -50,7 +83,7 @@ void ANERGUSCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCom
|
||||
if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(PlayerInputComponent))
|
||||
{
|
||||
// Jumping
|
||||
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &ANERGUSCharacter::DoJumpStart);
|
||||
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ANERGUSCharacter::DoJumpStart);
|
||||
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ANERGUSCharacter::DoJumpEnd);
|
||||
|
||||
// Moving
|
||||
@@ -67,6 +100,8 @@ void ANERGUSCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCom
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ANERGUSCharacter::MoveInput(const FInputActionValue& Value)
|
||||
{
|
||||
// get the Vector2D move axis
|
||||
@@ -80,10 +115,16 @@ void ANERGUSCharacter::MoveInput(const FInputActionValue& Value)
|
||||
void ANERGUSCharacter::LookInput(const FInputActionValue& Value)
|
||||
{
|
||||
// get the Vector2D look axis
|
||||
FVector2D LookAxisVector = Value.Get<FVector2D>();
|
||||
const FVector2D LookAxisValue = Value.Get<FVector2D>();
|
||||
|
||||
// pass the axis values to the aim input
|
||||
DoAim(LookAxisVector.X, LookAxisVector.Y);
|
||||
// DoAim(LookAxisVector.X, LookAxisVector.Y);
|
||||
|
||||
AddControllerYawInput(LookAxisValue.X);
|
||||
AddControllerPitchInput(LookAxisValue.Y);
|
||||
|
||||
CurrentLookInput = LookAxisValue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -118,3 +159,28 @@ void ANERGUSCharacter::DoJumpEnd()
|
||||
// pass StopJumping to the character
|
||||
StopJumping();
|
||||
}
|
||||
|
||||
void ANERGUSCharacter::SwayFunction(float DeltaTime)
|
||||
{
|
||||
FRotator SwayRotation = SwayComponent->GetRelativeRotation();
|
||||
FRotator LookTarget = FRotator(-CurrentLookInput.Y * 2.0f , CurrentLookInput.X * 2.0f , CurrentLookInput.X * 1.5f);
|
||||
|
||||
FVector CorrentVec = FVector(SwayRotation.Pitch,SwayRotation.Yaw,SwayRotation.Roll);
|
||||
FVector TargetVec = FVector(LookTarget.Pitch,LookTarget.Yaw,LookTarget.Roll);
|
||||
|
||||
FVector SmoothedVec = UKismetMathLibrary::VectorSpringInterp(CorrentVec, TargetVec, SwaySpringState, 40.0f, 0.7f, DeltaTime, 1.0f);
|
||||
|
||||
GEngine->AddOnScreenDebugMessage(1,1,FColor::White,FString::Printf(TEXT("SmoothedVec X = %f"), SmoothedVec.X));
|
||||
|
||||
SmoothedVec.X = FMath::Clamp(SmoothedVec.X, -10.0f, 10.0f);
|
||||
SmoothedVec.Y = FMath::Clamp(SmoothedVec.Y, -10.0f, 10.0f);
|
||||
SmoothedVec.Z = FMath::Clamp(SmoothedVec.Z, -10.0f, 10.0f);
|
||||
|
||||
GEngine->AddOnScreenDebugMessage(1,1,FColor::White,FString::Printf(TEXT("SmoothedVec X = %f"), SmoothedVec.X));
|
||||
GEngine->AddOnScreenDebugMessage(2,1,FColor::White,FString::Printf(TEXT("SmoothedVec Y = %f"), SmoothedVec.Y));
|
||||
GEngine->AddOnScreenDebugMessage(3,1,FColor::White,FString::Printf(TEXT("SmoothedVec Z = %f"), SmoothedVec.Z));
|
||||
|
||||
SwayComponent->SetRelativeRotation(FRotator(SmoothedVec.X , SmoothedVec.Y , SmoothedVec.Z));
|
||||
|
||||
CurrentLookInput = FVector2D::ZeroVector;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/SphereComponent.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#include "Logging/LogMacros.h"
|
||||
#include "NERGUSCharacter.generated.h"
|
||||
|
||||
class UInputComponent;
|
||||
class USkeletalMeshComponent;
|
||||
class USpringArmComponent;
|
||||
class UCameraComponent;
|
||||
class UInputAction;
|
||||
class USceneComponent;
|
||||
|
||||
struct FInputActionValue;
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All);
|
||||
@@ -31,6 +36,17 @@ class ANERGUSCharacter : public ACharacter
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true"))
|
||||
UCameraComponent* FirstPersonCameraComponent;
|
||||
|
||||
/** First person SpringArm */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Components", meta = (AllowPrivateAccess = "true"))
|
||||
USpringArmComponent* FirstPersonSpringArm;
|
||||
|
||||
/** Pawn mesh: first person view (arms; seen only by self) */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true"))
|
||||
USkeletalMeshComponent* FirstPersonArmMesh;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components", meta = (AllowPrivateAccess = "true"))
|
||||
USphereComponent* SwayComponent;
|
||||
|
||||
protected:
|
||||
|
||||
/** Jump Input Action */
|
||||
@@ -49,6 +65,16 @@ protected:
|
||||
UPROPERTY(EditAnywhere, Category ="Input")
|
||||
class UInputAction* MouseLookAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="Sway")
|
||||
FVector2D CurrentLookInput;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="Sway")
|
||||
FVector2D CurrentMoveInput;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="Sway")
|
||||
FVectorSpringState SwaySpringState;
|
||||
|
||||
|
||||
public:
|
||||
ANERGUSCharacter();
|
||||
|
||||
@@ -76,6 +102,9 @@ protected:
|
||||
UFUNCTION(BlueprintCallable, Category="Input")
|
||||
virtual void DoJumpEnd();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Sway")
|
||||
void SwayFunction(float DeltaTime);
|
||||
|
||||
protected:
|
||||
|
||||
/** Set up input action bindings */
|
||||
@@ -90,5 +119,8 @@ public:
|
||||
/** Returns first person camera component **/
|
||||
UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; }
|
||||
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user