I am working on a factory simulation project, and I want to change the shape and color of a mesh in game. For example, think of a sheet of steel getting bent or heated in different parts. the color and shape would change depending on where I bend or heat. I was looking up on vertices since they are what make a 3d model or a mesh ( I assume they are same or similiar), but not getting much progress on it. Is there a way to do this dynamically in game?
TLDR;
How can I simulate a steel sheet getting bent or heated in different positions dynamically.?
Hey there @user_00bdada99a4e2ca5478923e68f67e862b2ec3c23d08c5cf89805c5! So this question depends how much you need to manipulate the metal. The Materials portion is the less complex part, in that you can dynamically change the material using parameters. However, manipulating the mesh itself is going to be the complex part here.
If the metal is just bending a direction, but still remaining roughly the same object just bent, you could get away with using a skeletal mesh and animation for the deformation. However this is limited if the shape needs to change drastically.
If the deformation is really simple, you could technically do much of it inside of the material with World position offset, but this is likely not the best move for something like sheet metal.
If you need really complex and dynamic deformation you might be looking into runtime mesh manipulation. This is way overkill for most use cases and will be the hardest to implement of the three. However it has the greatest ability to manipulate a mesh in almost any way you want.
If you need help deciding, can you show me an example of what you’re going for? I can probably tell you which would work best/easiest implementation ad grab more targetted resources for the mesh manipulation you’re going for. Below I’ve linked some resources that will help you with getting into the material instances, parameters, and one to help you use world position inside of materials. Though you’ll still have to apply a mask of sorts to change the base color (and emission) of the material in a good position based on the flame. I would recommend a sphere mask and feather it depending on how the metal actually is though.
Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.
How to use material parameters:
Basics of material instances:
How to manipulate those parameters in BP:
How to use world position in materials (how you’d get the flame’s location on the material so you can change what you need on it):
I think I’ll have to go the way of mesh manipulation to make sure that it could be used in different types of simulations such as rolling the sheet or flattening a block of metal. My initial thought was getting an array of vertices of a mesh and changing the positions, which would change how the mesh looks like. I’m not sure if this is mesh manipulating or not. Could you give some more information about mesh manipulating? I’m new to working with 3d models and it is quite hard to even understand the context of what people are talking about in the forums.
For changing colors I’ll have to use world position and sphere mask to change the color of the mask depending on the position right?
Thank you so much for showing me the direction to search for!
Alright! So mesh manipulation is the most complex and expensive performance wise of the three. Since your use case is closer to simulation, you may not have to worry so much about regular in game concerns that many developers have to face. You’re correct that adjusting the vertexes would work for your case, however static meshes themselves are cooked thus cannot be edited at runtime (other than using World Position Offset in the material). This leads us to Procedural Mesh Component or Dynamic Mesh Component.
There are scant resources for learning these top to bottom, but the best resource I could muster handles most of the teaching, the downside is that much of it is in C++ (while more of it is now exposed to blueprints, this was not the case at the time of the guide)
Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.
This is going to be a bit of a deep dive, so I recommend lots of coffee! (if that’s your thing).
No worries! Be sure to watch his attached videos as well, they are quite useful. This is actually where I learned to initially start working with mesh generation. There’s not too many users that understand this that also make tutorial content, so finding resources can be a problem. I’d definitely start with the most basic manipulations and then see how far you can push it, but this is a deep subject. During the process if you have issues, feel free to post questions to the community as well! I know there are a few users well versed in mesh generation that are around on a decent basis that could provide stronger direct assistance than me on this subject.