diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 7195bf46..189f8513 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -76,8 +76,13 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent* } } +//When 1 is pressed it calls EquipPrimary void AEndlessVendettaCharacter::EquipPrimary() { + //If primary weapon is not there but secondary weapon is it will call equipSecondary. + //EquipSecondary checks and sees that secondary is there so it will call to destroy itself + //Code goes back and sees primary weapon is not there anymore and spawns it in. + //Same thing for the EquipSecondary() if (!IsValid(PrimaryWeapon)) { if (IsValid(SecondaryWeapon)) EquipSecondary(); @@ -87,8 +92,11 @@ void AEndlessVendettaCharacter::EquipPrimary() FActorSpawnParameters spawnParams; spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true); + //Creating a new actor object called PrimaryWeapon that is based off primaryweaponClass AActor* PrimaryWeaponActor = GetWorld()->SpawnActor(PrimaryWeaponClass, spawnParams); PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint")); + //Changing PrimaryWeaponActor to ABaseWeaponClass type instead of actor and storing it into PrimaryWeapon which is a ABaseClass Object + //We do this because we need to check if PrimaryWeapon is equipped and we want primaryweapon to be ABaseWeapon type and not a generic AActor PrimaryWeapon = Cast(PrimaryWeaponActor); }