# "If Statements" to control Material parameters?

**URL:** <https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282>\
**Category:** Character & Animation\
**Tags:** unreal-engine, editor, Blueprint, question\
**Created:** [February 23, 2023, 6:13pm UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282 "2023-02-23T18:13:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean3Dmonkey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean3Dmonkey](https://forums.unrealengine.com/u/Sean3Dmonkey)\
**Post date:** [February 23, 2023, 6:13pm UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/1 "2023-02-23T18:13:59Z")

</div>

How would I use If Statements to control Material parameters? I wish to manually animate the position of UVs.

1. If a variable has a value of 0, offset the UV tile to these U and V parameter values.

2. If the same variable has a value of 1, offset the UV tile to these **different** U and V parameter values?

3. If the same variable has a value of 2, offset the UV tile to these **different** U and V parameter values?

 ![U and V offset parameters](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/5/b/15bc12cf89d9934092790af6887f7c7a7501af9c.png)

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 23, 2023, 6:28pm UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/2 "2023-02-23T18:28:12Z")

</div>

There is a node for that:  
 ![afbeelding](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/0/2/90208b3bba99624c83ab6b4063fc4d4b8a1c8198.png)

It works similar to the “select” node in blueprints. You can chain them into a final output.

---

<div class="post-metadata">

**Author:** ![Sean3Dmonkey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean3Dmonkey](https://forums.unrealengine.com/u/Sean3Dmonkey)\
**Post date:** [February 23, 2023, 7:40pm UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/3 "2023-02-23T19:40:49Z")

</div>

> [@Roy\_Wierer.Seda145](#):
>
> You can chain them into a final output.

Hello Roy, may I ask a few more questions?

1. Does this screen grab of **“If statements”** look correct?  
a. Did I set up the If “A” and “B” values correctly?

2. Would I use a **Dynamic Material Instance** to connect the variable to the Material Parameters?

3. What node may I use to **chain** all the If Statements to the Flipbook?

 ![Question Flipbook](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/7/9/f79a8ac97bff2e55c0449ca1048261d18fea69ad.jpeg)

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 23, 2023, 9:48pm UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/4 "2023-02-23T21:48:27Z")

</div>

> [@Sean3Dmonkey](#):
>
> Would I use a **Dynamic Material Instance** to connect the variable to the Material Parameters?

1. That is right, you can read more about dynamic instances and parameter access here:

> [Instanced Materials | Unreal Engine 4.27 Documentation](https://docs.unrealengine.com/4.27/en-US/RenderingAndGraphics/Materials/MaterialInstances/)

> [How to access a material instance variable from a blueprint object in Unreal Engine? - #4 by Fenther586](https://forums.unrealengine.com/t/how-to-access-a-material-instance-variable-from-a-blueprint-object-in-unreal-engine/475565/4)

1. , 3. the node shows an error, so you probably have to add a node to an input pin or use a different type, the error will tell. It’s a bit messy in materials but usually you link the output pin of one IF node into an input pin (A or B) of another IF node. That is how you create a chain. You might come up with a cleaner alternative in BP to use as parameter.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 23, 2023, 9:51pm UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/5 "2023-02-23T21:51:39Z")

</div>

Why are there multiple parameters for the UV offset though? Wouldn’t it make sense to have 1 parameter to offset the UV and take the logic to set the parameter out of the material?

---

<div class="post-metadata">

**Author:** ![Sean3Dmonkey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean3Dmonkey](https://forums.unrealengine.com/u/Sean3Dmonkey)\
**Post date:** [February 24, 2023, 1:56am UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/6 "2023-02-24T01:56:09Z")

</div>

I have never done this sort of thing before; just feeling my way to a solution; trying to learn.

I don’t know how to use 1 parameter to offset the UV and take the logic to set the parameter out of the material.

As a Newby, it just made sense to itemize each Offset out into separate params. To make it easy for a Newby to understand.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 24, 2023, 2:42am UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/7 "2023-02-24T02:42:02Z")

</div>

> [https://www.youtube.com/watch?v=i4Z2r7mGA0o](https://www.youtube.com/watch?v=i4Z2r7mGA0o)

> [https://www.youtube.com/watch?v=yVMyXZzScsY](https://www.youtube.com/watch?v=yVMyXZzScsY)

---

<div class="post-metadata">

**Author:** ![Sean3Dmonkey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean3Dmonkey](https://forums.unrealengine.com/u/Sean3Dmonkey)\
**Post date:** [February 24, 2023, 10:19pm UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/8 "2023-02-24T22:19:59Z")

</div>

> [@Roy\_Wierer.Seda145](#):
>
> Wouldn’t it make sense to have 1 parameter to offset the UV and take the logic to set the parameter out of the material?

Hello Roy, I think I got most of it.

1. I’m using a Dynamic Material Instance to provide the value to the material.

2. Question: About the last If Statement in the chain. What would I plug into the A\>B to make the error go away? I want the UV to stay where it is “OffsetU IF 2 = 1.5” and “OffsetV IF 2 = 0.0”  
a. If I wire the same Append into A\>B, I get an additional Error in the If Statement chain above the current if statement.  
b. Question: How would I make the if A\>B do nothing; don’t move the UV to other param coordinates?

 ![If statement](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/7/4/a74d45559ada76d481d12d48995f942957926c68.png)

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 25, 2023, 5:45pm UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/9 "2023-02-25T17:45:29Z")

</div>

I think you don’t yet understand the IF node.  
the node on the screenshot says:

if A \> B then nothing.  
if A == B (3) then append param 1 with param 2.  
if A \< B (3) then append param 1 with param 2.

“Nothing” is not a valid input for a pin. If you don’t want to add an offset if A \> B then add a constant of 0 to the A \> B pin.

---

<div class="post-metadata">

**Author:** ![Sean3Dmonkey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean3Dmonkey](https://forums.unrealengine.com/u/Sean3Dmonkey)\
**Post date:** [February 25, 2023, 7:51pm UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/10 "2023-02-25T19:51:26Z")

</div>

Correct, I do not know how to properly use an If Statement in a Material…trying to learn.

I used a constant with a value of 0, but I then discovered an error in the If Statement above the current If Statement.

I probably built the If Statement chain wrong, too.

 ![If Statement 2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/5/5/955a636c3aa6a9c3f2f0ce1e21c67e05e24496b4.png)

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 25, 2023, 7:57pm UTC](https://forums.unrealengine.com/t/if-statements-to-control-material-parameters/777282/11 "2023-02-25T19:57:48Z")

</div>

The if nodes generating the same errors also need an input value for the input pins
