diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset index a993997e..68a7823a 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3192f3e53f9cde4484a9e8fd75184a71bf9ea1da5876fee94ceded15c274685a -size 26191 +oid sha256:072d87c768407249e6e50f7b87ab9a88392c17cf82c72934e3c947e2943210bb +size 26284 diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index b54d9bab..1f728d05 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -54,7 +54,13 @@ void AEndlessVendettaCharacter::BeginPlay() GadgetManager = Cast(GadgetManagerActor); FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true); GadgetManagerActor->AttachToComponent(GetRootComponent(), AttachmentRules); - GadgetManager->SpawnGadgets(GetRootComponent()); + for (UActorComponent* PlayersCamera : GetComponentsByTag(UCameraComponent::StaticClass(), FName("PlayersCamera"))) + { + UE_LOG(LogTemp, Warning, TEXT("An actor component with PlayersCamera tag has been found")); + GadgetManager->SpawnGadgets(Cast(PlayersCamera)); + break; + } + } //////////////////////////////////////////////////////////////////////////// Input diff --git a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetBase.h b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetBase.h index 37f5190e..50917ebb 100644 --- a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetBase.h +++ b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetBase.h @@ -32,6 +32,9 @@ protected: UPROPERTY(EditDefaultsOnly, Category = "Gadget") FVector EquippedOffset = FVector(0, 0, 0); + UPROPERTY(EditDefaultsOnly, Category = "Gadget") + FRotator GadgetRotation = FRotator(0, 0, 0); + UPROPERTY(EditDefaultsOnly, CAtegory = "Gadget") FVector UnequippedOffset = FVector(0, 0, -1000); @@ -73,7 +76,11 @@ public: { return UnequippedOffset; } - + + FRotator GetGadgetSpawnRotation() + { + return GadgetRotation; + } // Sets default values for this actor's properties AGadgetBase(); diff --git a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetManager.cpp b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetManager.cpp index 6e5a8ee4..8f7c6aa0 100644 --- a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetManager.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetManager.cpp @@ -25,7 +25,7 @@ void AGadgetManager::Tick(float DeltaTime) } -void AGadgetManager::SpawnGadgets(USceneComponent* PlayersRootComponent) +void AGadgetManager::SpawnGadgets(USceneComponent* PlayersCameraComponent) { if (!IsValid(ReconClass) || !IsValid(CombatClass)) UE_LOG(LogTemp, Fatal, TEXT("Recon or Combat class hasn't been set")); @@ -35,11 +35,13 @@ void AGadgetManager::SpawnGadgets(USceneComponent* PlayersRootComponent) AActor* SpawnedActor = GetWorld()->SpawnActor(ReconClass, GetActorLocation(), GetActorRotation(), SpawnParams); ReconGadget = Cast(SpawnedActor); - SpawnedActor->AttachToComponent(PlayersRootComponent, AttachmentRules); + SpawnedActor->AttachToComponent(PlayersCameraComponent, AttachmentRules); SpawnedActor->SetActorRelativeLocation(ReconGadget->GetUnequippedOffset()); + SpawnedActor->SetActorRelativeRotation(ReconGadget->GetGadgetSpawnRotation()); SpawnedActor = GetWorld()->SpawnActor(CombatClass, GetActorLocation(), GetActorRotation(), SpawnParams); CombatGadget = Cast(SpawnedActor); - SpawnedActor->AttachToComponent(PlayersRootComponent, AttachmentRules); + SpawnedActor->AttachToComponent(PlayersCameraComponent, AttachmentRules); SpawnedActor->SetActorRelativeLocation(CombatGadget->GetUnequippedOffset()); + SpawnedActor->SetActorRelativeRotation(CombatGadget->GetGadgetSpawnRotation()); } diff --git a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetManager.h b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetManager.h index 7935ac0d..686b2516 100644 --- a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetManager.h +++ b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetManager.h @@ -26,7 +26,7 @@ protected: virtual void BeginPlay() override; public: - void SpawnGadgets(USceneComponent* PlayersRootComponent); + void SpawnGadgets(USceneComponent* PlayersCameraComponent); // Sets default values for this actor's properties AGadgetManager();