Added Comments to increase readability
This commit is contained in:
parent
1432b479b2
commit
64fc74c5fc
@ -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<AActor>(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<ABaseWeaponClass>(PrimaryWeaponActor);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user