Dynamic (car) deformation with Blueprints - Unreal Engine 5 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello people I hope you have a nice day in this video I want to show you how I created the deformation effect on cars like in my previous videos and all of that in blueprints no cating required have a look at what you can achieve after this tutorial you might add some extra work though okay now I want to talk about the techniques I used what the advantages and disadvantages are at the core the built-in procedural mesh component is responsible for most of the work through it it is possible to build and manipulate meshes at runtime this flexibility was the reason why I chose this approach over all the others epic for example uses skeletal meshes in their Matrix demo while the performance and mesh complexity May profit from this it is a tedious task to rig every model by hand on the downside the procedural mesh component isn't very performant I haven't found a way other than to Loop through every vertex and compare the distance to the one of the hit point this means that the meshes used for the vehicles or every other case you may find this useful in can't have too many polygons but you also can't have too many of those blueprints in your level and active at the same time otherwise you may fry your CPU or what's more likely crash the engine for some more Beauty the vertex colors are colored the same time as each vertex is deformed I use the red Channel and later had access to it in the material I only used one material instance and one mesh in this case but it's definitely possible to use more anyways with the vertex colors I blended between an undamaged and busted albo map but also made a wrinkled normal map appear for a little more detail by the way I used the advanced vehicle system from 747 for the driving mechanics and physics of the car this isn't mandatory though I only choose it because the setup is quite easy and I got it for free a while back sadly this plugin has also a major drawback which I'll talk about later I got the model from the generic passenger car pack which you can see here I'll probably put the exact model and materials I used in the description as a downloadable link because I had some merging to do before using any of the models so now that all this info is out of the way let's start creating the parent blueprint links to the blueprints on blueprint. are also in the description let's begin with adding everything we need which isn't much only the PMC and a spring arm with a camera attached to it the later is optional as I will focus mainly on the deformation part here then create all the variables we need to manipulate the mesh and reset it if we wanted to I won't go over every one of them you can see what we need if you aren't as experienced with blueprints the checkerboard pattern means the variable is an RA we only need to expose the static mesh and material variables as we need to change them later on in the children in the construction script we'll store all the initial values for future processing looping through every vertex assures us to have the correct amount of vertex colors then the variables are assigned their corresponding values outputed by the get Section from static mesh node in the end the procedural mesh component is Created from that data and assigned its material the problem with the AVS Plus is that it has to use the Collision of a static mesh sadly in that way you can't make use of the dynamic recalculation of collisions of the PMC after adding a on component hit event on the main collider remember to check simulation generates hit events or else it won't work the first thing to do is to calculate the strength of the impact depending on if the other component that has been hit is simulating physics its velocity and mass will be considered then these values are offset against the cars I set a threshold of 0.03 which has to be exceeded the do once node will ensure not to do the calculations too often just for safety so your PC doesn't explode we have to create two functions one for getting all the points inside a certain radius and another to do all the changes to the selected vertices getting all the points isn't to complicated really We're looping through all the points we previously stored inside the vertica variable compare its distance to the hit point and then also adding an element to the output array for looking up the strength by which it has to be deformed by for that the distance is divided by the radius that result is square Ed inverted and offset by one here you can see what the corresponding graph looks like now all the changes to the mesh can be made again a for Loop is used to go through all the found points the variable which contains the vertices to build the mesh is then changed substracting its position by the deform strength times the impact strength times the original position will us give the result we want to achieve keep in mind though that this will result in deformation towards the vehicle Center I tried to deform them with the hit Vector but got no feasible result so far maybe you can find a solution to that if you do let me know in the comments afterwards something is added to the red vertex colors Channel value if we want to at least okay so that's all the hard work we had to do inside the blueprint now the mesh section only has to be updated and the do once node with a delay reset I chose a value of 0.25 seconds the play sound at location as well as the reposition Wheels after impact are optional if you want to know more about the ladder have a look in the video description now to the material the red vertex color we previously set inside the blueprint is now used to interpolate between the intact and damaged albo of the vehicle with the multiply and clamp node the transition can be hardened because a soft transition looks rather unnatural the same output is then used for the blending of the bumpy normal map as well the name of the normal map is tore water normal 0 1core n it should come with your project the rest is pretty much standard material stuff specular metallic and everything else you want to change finally we have to create a child blueprint class give it a name you like and open it we only have to assign our mesh and the material if you also use the ABS plug-in you can now add the wheels and all the other things then drop the BP in the level and choose player zero for the autop possessed player in the details menu have fun driving around as I said earlier I mainly focused on the process of deformation how you can make the car drivable has to be looked up in another tutorial I'll link some helpful articles in the description if you have trouble with that I hope this tutorial was somewhat helpful and interesting feel free to ask me anything in the comments PE
Info
Channel: blu kettle
Views: 2,607
Rating: undefined out of 5
Keywords: Unreal, Unreal Engine, Unreal Engine 5, Tutorial, Blueprints, Car, Vehicle, Deformation, Collision
Id: Y2FCXlDVUck
Channel Id: undefined
Length: 8min 13sec (493 seconds)
Published: Fri Dec 29 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.