"If Statements" to control Material parameters?

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?

There is a node for that:
afbeelding

It works similar to the “select” node in blueprints. 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?

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

Instanced Materials | Unreal Engine 4.27 Documentation

How to access a material instance variable from a blueprint object in Unreal Engine? - #4 by Fenther586

  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.

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?

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.

https://www.youtube.com/watch?v=i4Z2r7mGA0o

https://www.youtube.com/watch?v=yVMyXZzScsY

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?

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.

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.

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