# Blueprint loop/for/while node with custom c++ blueprint function library

**URL:** <https://forums.unrealengine.com/t/blueprint-loop-for-while-node-with-custom-c-blueprint-function-library/458043>\
**Category:** Audio\
**Tags:** unreal-engine, nodes, loop, Scripting, question\
**Created:** [November 5, 2019, 9:05am UTC](https://forums.unrealengine.com/t/blueprint-loop-for-while-node-with-custom-c-blueprint-function-library/458043 "2019-11-05T09:05:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AaroTT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AaroTT](https://forums.unrealengine.com/u/AaroTT)\
**Post date:** [November 5, 2019, 9:05am UTC](https://forums.unrealengine.com/t/blueprint-loop-for-while-node-with-custom-c-blueprint-function-library/458043/1 "2019-11-05T09:05:14Z")

</div>

Hi,

I need to create a custom blueprint node. I am using the blueprint function library.

The node will look like this:

Input:  
int timedelayforeachloop  
int numberofloops

output  
exc loop  
exc completed

loop1.h

```
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "loop1.generated.h"

/**
 * 
 */

UENUM(BlueprintType)
enum class EMultiBranchEnum1 : uint8
{
	BranchA,
	BranchB
};

UCLASS()
class MYPROJECT2_API Uloop1 : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
		UFUNCTION(BlueprintCallable, meta = (DisplayName = "loop", CompactNodeTitle = "2as2", ExpandEnumAsExecs = "Branches"), Category = "1")
		//UFUNCTION(BlueprintCallable, Meta = (DisplayName = "Multi Branch1", ExpandEnumAsExecs = "Branches"), Category = 1)
		static void multiBranch(EMultiBranchEnum1& Branches, int loopqty);
	    //EMultiBranchEnum1::BranchB;
	
};

```

loop1.cpp

```
// Fill out your copyright notice in the Description page of Project Settings.

#include "loop1.h"

void Uloop1::multiBranch(EMultiBranchEnum1& Branches, int loopqty)
{

	int currloop1 = 0;
	int temp = 2;
	int i;
	for (i = 0; i < 10; i++){
		currloop1 = currloop1 + 1;
		Branches = EMultiBranchEnum1::BranchA;
		
		
	}
	
	if (temp > currloop1) {

		Branches = EMultiBranchEnum1::BranchB;
	}
		
	if(temp == 0) {

		Branches = EMultiBranchEnum1::BranchB;

	}

}

```

– THE PROBLEM –  
The for loop only runs the once (evident by the print node i have on branchA(It only prints a single time))

– What should happen with the code below –  
the loop should run the 10 times (my print node should print 10 times)

---

<div class="post-metadata">

**Author:** ![jorg1234](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jorg1234](https://forums.unrealengine.com/u/jorg1234)\
**Post date:** [August 21, 2021, 10:43am UTC](https://forums.unrealengine.com/t/blueprint-loop-for-while-node-with-custom-c-blueprint-function-library/458043/2 "2021-08-21T10:43:40Z")

</div>

Hi! Did you ever solve this?

---

<div class="post-metadata">

**Author:** ![NorexDev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NorexDev](https://forums.unrealengine.com/u/NorexDev)\
**Post date:** [August 21, 2021, 8:23pm UTC](https://forums.unrealengine.com/t/blueprint-loop-for-while-node-with-custom-c-blueprint-function-library/458043/3 "2021-08-21T20:23:35Z")

</div>

no I stopped learning c++
