Loop in Tick Called Function

I’m running the following code:

void AFEWeapon_Projectile::FireWeapon()
{
	const FVector StartTrace = GetMuzzleLocation();
	const FVector ShootDir = GetAdjustedAim();

	SpawnProjectile(StartTrace, ShootDir, true, FColor::Red); //Set debugging manually if desired
}

void AFEWeapon_Projectile::SpawnProjectile(FVector Origin, FVector Direction, bool debug, FColor debugcolor)
{
	ActiveProjectiles.Add(FProjectile(Origin, Direction, ProjectileVelocity, debug, debugcolor));
}

void AFEWeapon_Projectile::UpdateProjectiles()
{
	int i = 0;
	for (FProjectile fp : ActiveProjectiles)
	{
		fp.Update(GetWorld());
		i++;
		//Process hit results after the projectile has been updated
	}
	UE_LOG(LogTemp, Warning, TEXT("Loop iterations: %d"), i);
}

FHitResult AFEWeapon_Projectile::WeaponTrace()
{
	return FHitResult();
}

void AFEWeapon_Projectile::ProcessHit()
{

}

void AFEWeapon_Projectile::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	UpdateProjectiles();
}

This is supposed to update the TArray ActiveProjectiles. However the logging from UpdateProjectiles() looks like this:

LogTemp:Warning: Loop iterations: 0
LogTemp:Warning: Loop iterations: 1
LogTemp:Warning: Loop iterations: 0
LogTemp:Warning: Loop iterations: 1
LogTemp:Warning: Loop iterations: 0
LogTemp:Warning: Loop iterations: 1

Why is this happening? It also seems to be causing the calls to Update() for my USTRUCTS to not work properly. What causes the loop to run inconsistently? Is tick a bad method to use here?

Is it possible that you have 2 instances of AFEWeapon_Projectile in the game ? Thus, when you FireWeapon, only one of them really spawn an object. If you call FireWeapon a second time, do you get :

LogTemp:Warning: Loop iterations: 0
LogTemp:Warning: Loop iterations: 2

Try adding more infos like :
UE_LOG(LogTemp, Warning, TEXT(“[%s] Loop iterations: %d”), *GetName(), i);

PS : You should use a reference in your for loop to avoid copies (in general it is for optimization but here, it is more to be sure that is not a copy issue) :

for (FProjectile& fp : ActiveProjectiles)
{
   ...
}

That did it… it was the reference issue. I’m a python programmer by trade, I’m used to everything being references automatically. Thanks for all the help!