Not to be confused with instanced static meshes.
I am looking for a way to move down 50 different parts of a mesh using the material at runtime. However, the challenge is that these parts are not predetermined and need to be selected at runtime specifically.
Like having an army of cubes as one mesh, and being able to move a part of that mesh, that is 50 cubes merged (still one mesh).
I have explored two methods online, each with its own limitations. The first method involves using vertex colors, but this would require that i can paint the specific vertices at runtime so i can target one part of the mesh.
The second method involves using a texture mask for each part that needs to be moved, where black is used for the parts that should not move and white for the parts that should be moved. However, the problem with this method is that I need to add white to the texture for each of the 50 parts, which is not practical, and dont know if that would work.
Here is the basic sketch that illustrates what im trying to do:
This is one merged mesh of cubes. Just one static mesh.
You can see how i first chose to move that one cube, by painting it white.
Then as i want to move them i paint them white.
I am open to other ideas or methods for achieving this. Is there a better way to move multiple parts of a mesh using the material at runtime? Your suggestions and insights would be greatly appreciated.
Why not just have 50 cube meshes. Are you just trying to make your life difficult? 
Or even, 50 cubes in one blueprint. You can have the ‘one thing feeling’ there, and still get to move them around.
2 Likes
Its for a school project. The professor proposed this challenge.
I know there are other ways. We need to have one mesh, and in one material move parts of the mesh down.
1 Like
Ok, then it’s WPO ( world position offset ). You can move the whole mesh up and down with that. So if you have a selective mask, then you can just move parts of it up and down.
You could also use a simple B&W texture ( possibly left and right half, or possibly a B&W quad ) with UV manipulation to move just one of them…
Just looking at your spec again, it would either be a square mask with an outline and UV fiddling, or a mask that looks like the row of cubes, multiplied by copies of a single square. Something like that 
1 Like
I accidently click to confirm as the solution. I wanted to press like.
Well its on the path to become the solution.
Its fine.
So i have more questions…
If i select a cube using a B&W mask as you said, how can i at run time select the right cube?
Do i need many different texture combinations for that?
Or i need to make a texture at run time?
1 Like
You can untick it 
I’m just fiddling with this idea at the mo…
1 Like
Ah, one thing. They only need to be moved down. So its nothing very complex.
1 Like
I’m getting too tired here, might have to come back tomorrow on this one.
I’m messing around with a linear gradient node and ‘absolute world position’ node, into world position offset.
Gonna soldier on for a bit…
1 Like
Thank you.
I think that it might be possible. If i create a texture at runtime? But its a bit complicated.
And i guess that would require for each static mesh to have its own texture and material.
However if we can move on vertex. Like moving vertexes by number. I dont know if thats possible.
I got another crazy idea:
Have many shades of colors assigned to different cubes that compose the mesh.
Then hide them by color, or by vertex color.
This would work?
I’m getting there…
I’ll bet it’s someting to do with this process
You see you can make black and white lines ( it is 0 and 1 ), by fiddling with UV coords.
All you have to do ( ha ha ), is figure out how to use these lines to either multiply the current cube by a shifted Z coordinate or not.
A shifted Z is

fed into the WPO.
So I made this ( not proud )
It does the same UV trick, but does it with the X distance from the pivot point. Two things really matter
-
Where the pivot of the mesh is
-
Having the cubes evenly spaced ( there is exactly a cube missing between each of the cubes ). It is one mesh.
With the material instance like this
I get, wait for it…

Like I say, it is one mesh it’s normal state is this
There probably is a much more streamlined way, but this does the trick.
2 Likes
Thats amazing. So then all i have to do to hide one cube is just puttin a line in the correct coordinates.
A thing i forgot to say is that its not necessary to move the cube. But just to hide it.
Though moving it might be cheaper.
By vertex color:
I came up with a different solution. Though im afraid this might be expensive.
That is to assign a color to the vertices in blender.
Then in the material I use a Per Instance Custom Data Value to hide the cube that is dead:
So i tested with 3 cubes with red green and blue, and it works amazingly well.
Here is how the material looks like:
The only issue with this is that it needs one vertex color per part of the mesh you want to destroy.
Then just remove them like this:
What do you think of this, like in terms of performance?
That’s very fancy, well done 
In terms of expense, it’s probably similar, but it is more complex.
I think there is a UV solution, rather than offset from pivot, but can’t quite grasp it right now.
PS, I had to add that offset to the object pivot in the material, because it’s in the middle of the first cube.
If it’s just making them disappear, you could probably use this ‘floor’ concept to make the mask.
1 Like
The UV solution i think its even more complicated i think. But i dont know.
Maybe there is something im not aware of.
But the UV means creating a texture that selects parts of the mesh.
That means either:
A) Having many textures for each possible combination.
B) Creating a texture at runtime. Messy.
C) something i dont know.
Naturally, I couldn’t sleep properly last night 
I spent the whole night wondering about a cube or sphere mask. It would be very easy.
Do you have to do the whole thing in the material, or is BP allowed?
1 Like
That is awesome.
But that hides just one cube? What happens when we need to hide more cubes?
Then we would need to create extra boxes?
Or should it start with one hiding box per part we want to hide?
Yes, you can make the box longer to hide a group. Or have more than one box…
1 Like