Update Character for Procedural Aiming & Character Parenting

This commit is contained in:
Philip W 2024-03-06 18:13:46 +00:00
parent e8c3a10c57
commit 1fd59390ff
26 changed files with 75 additions and 68 deletions

Binary file not shown.

Binary file not shown.

View File

@ -31,20 +31,20 @@ AEndlessVendettaCharacter::AEndlessVendettaCharacter()
// Set size for collision capsule // Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(55.f, 96.0f); GetCapsuleComponent()->InitCapsuleSize(55.f, 96.0f);
// Create a CameraComponent // // Create a CameraComponent
FirstPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera")); // FirstPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera"));
FirstPersonCameraComponent->SetupAttachment(GetCapsuleComponent()); // FirstPersonCameraComponent->SetupAttachment(GetCapsuleComponent());
FirstPersonCameraComponent->SetRelativeLocation(FVector(-10.f, 0.f, 60.f)); // Position the camera // FirstPersonCameraComponent->SetRelativeLocation(FVector(-10.f, 0.f, 60.f)); // Position the camera
FirstPersonCameraComponent->bUsePawnControlRotation = true; // FirstPersonCameraComponent->bUsePawnControlRotation = true;
//
// Create a mesh component that will be used when being viewed from a '1st person' view (when controlling this pawn) // // Create a mesh component that will be used when being viewed from a '1st person' view (when controlling this pawn)
Mesh1P = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("CharacterMesh1P")); // Mesh1P = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("CharacterMesh1P"));
Mesh1P->SetOnlyOwnerSee(true); // Mesh1P->SetOnlyOwnerSee(true);
Mesh1P->SetupAttachment(FirstPersonCameraComponent); // Mesh1P->SetupAttachment(FirstPersonCameraComponent);
Mesh1P->bCastDynamicShadow = false; // Mesh1P->bCastDynamicShadow = false;
Mesh1P->CastShadow = false; // Mesh1P->CastShadow = false;
//Mesh1P->SetRelativeRotation(FRotator(0.9f, -19.19f, 5.2f)); // //Mesh1P->SetRelativeRotation(FRotator(0.9f, -19.19f, 5.2f));
Mesh1P->SetRelativeLocation(FVector(-30.f, 0.f, -150.f)); // Mesh1P->SetRelativeLocation(FVector(-30.f, 0.f, -150.f));
} }
void AEndlessVendettaCharacter::IncrementRestrictedBoundsCount() void AEndlessVendettaCharacter::IncrementRestrictedBoundsCount()
@ -105,6 +105,7 @@ void AEndlessVendettaCharacter::BeginPlay()
GadgetManagerActor->AttachToComponent(GetRootComponent(), AttachmentRules); GadgetManagerActor->AttachToComponent(GetRootComponent(), AttachmentRules);
for (UActorComponent* PlayersCamera : GetComponentsByTag(UCameraComponent::StaticClass(), FName("PlayersCamera"))) for (UActorComponent* PlayersCamera : GetComponentsByTag(UCameraComponent::StaticClass(), FName("PlayersCamera")))
{ {
FirstPersonCameraComponent = Cast<UCameraComponent>(PlayersCamera);
GadgetManager->SpawnGadgetsOnBeginPlay(Cast<USceneComponent>(PlayersCamera)); GadgetManager->SpawnGadgetsOnBeginPlay(Cast<USceneComponent>(PlayersCamera));
break; break;
} }
@ -210,16 +211,16 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent)) if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))
{ {
//Jumping //Jumping
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &ACharacter::Jump); // EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &ACharacter::Jump);
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping); // EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
//Moving //Moving
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Move); // EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Move);
EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Sprint); // EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Sprint);
EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopSprint); // EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopSprint);
//Looking //Looking
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look); // EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look);
// Gadget Toggling // Gadget Toggling
EnhancedInputComponent->BindAction(ReconAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::ToggleRecon); EnhancedInputComponent->BindAction(ReconAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::ToggleRecon);
@ -793,7 +794,7 @@ void AEndlessVendettaCharacter::HoldInteract()
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return; if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return; if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
FTransform TakeOffTransform = GetActorTransform(); FTransform TakeOffTransform = GetActorTransform();
FVector NewLoc = TakeOffTransform.GetLocation(); FVector NewLoc = TakeOffTransform.GetLocation();
NewLoc.Z += BikeRideHeight; NewLoc.Z += BikeRideHeight;

View File

@ -46,12 +46,12 @@ private:
UInputMappingContext* DefaultMappingContext; UInputMappingContext* DefaultMappingContext;
/** Jump Input Action */ /** Jump Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
UInputAction* JumpAction; // UInputAction* JumpAction;
/** Move Input Action */ /** Move Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
UInputAction* MoveAction; // UInputAction* MoveAction;
// Gadget Actions // Gadget Actions
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))
@ -176,8 +176,8 @@ public:
double MoveGroundSpeed; double MoveGroundSpeed;
/** Look Input Action */ /** Look Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* LookAction; // class UInputAction* LookAction;
/** Bool for AnimBP to switch to another animation set */ /** Bool for AnimBP to switch to another animation set */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Weapon) UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Weapon)