# How to Flow Control in Material Custom nodes?

**URL:** <https://forums.unrealengine.com/t/how-to-flow-control-in-material-custom-nodes/1389239>\
**Category:** FX\
**Tags:** UE-5, unreal-engine, question\
**Created:** [November 14, 2023, 6:33am UTC](https://forums.unrealengine.com/t/how-to-flow-control-in-material-custom-nodes/1389239 "2023-11-14T06:33:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [November 14, 2023, 6:33am UTC](https://forums.unrealengine.com/t/how-to-flow-control-in-material-custom-nodes/1389239/1 "2023-11-14T06:33:26Z")

</div>

I want a node work like IF-Else.  
I was thinking the “Code Expresson” work like C++… but i was wrong…

So… in this case, i want to use the Base Color ‘OR’ the emissive Color (Only one of them)

 ![1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/1/4/2144a1cad79ccec45054346c5b994538d8163290.png)

So, I tried this Code but it is not working like I expected.

`return (Bool ? BaseColor=A : Emissive=A);`

Any way to do what i want?

Thank you so much!!

* * *

UPDATE:

* * *

Ok… this way does work!!

But seems to be an unnecessarily complicated way.

 ![2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/2/3c2b0a98abb6bd2838170de0fb8b263e14f683fa.png)

How can i do the same in a single custom node?  
Thank you so much!!

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [November 14, 2023, 10:40am UTC](https://forums.unrealengine.com/t/how-to-flow-control-in-material-custom-nodes/1389239/2 "2023-11-14T10:40:57Z")

</div>

This works!!

```auto
if(BoolValue>0.0f)
{
	BaseColor=A;
	Emissive = float3(0.0f,0.0f, 0.0f);
	return BaseColor;
}
else
{
	BaseColor=float3(0.0f,0.0f,0.0f);
	Emissive=A;
	return Emissive;
}

```

For some reason the name “Bool” caused the error… must be a internal reservate word. So, i renamed it to “BoolValue” and it does work.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [December 14, 2023, 10:41am UTC](https://forums.unrealengine.com/t/how-to-flow-control-in-material-custom-nodes/1389239/3 "2023-12-14T10:41:05Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
