Wing flex
Big thanks toG-Gorce Guy for introducing me how to bend wings in Assetto Corsa
Last updated
Big thanks toG-Gorce Guy for introducing me how to bend wings in Assetto Corsa
Last updated
CSP improves on Assetto Corsa default engine and allows us to move some parts of the car more realistically. When you speed up or go over a kerb, the front wing does wobble and bends due to aerodynamic forces. This can be replicated thanks to CSP.
First of all, we must add bones to the front wing. These bones will make parts of the front wing move.
We need to isolate everything related to the front wing, if the front wing is part of the car body object, split it into several pieces and join every part related to the front wing again. For example in this car, I have 3 parts : The front wing skin, the carbon part, and the rivets.
Load the bones from this blend, and isolate the front wing
Move the bones toward the center of the front wing
Now move the 1st bone to the end of the moving part of the front wing (the big left part here). Be in edit mode to move the bone.
Move the second bone to the extremity of the part holding the front wing to the nose
Do the same thing with the right bones and it should look like this :
Now that this is done let's fix the direction of the wing. Assetto Corsa needs the Y axis to be on top, so we will make the Y axis of the front wing face the top. Select the front wing parts, go to active tools, and select "Affect Only" = Origins.
Use the rotation tool to see the 3 axes of the object.
If Y is not on top, press the following keys on your keyboard R + X + 90 (this will rotate the object by 90 degrees on the X axis, which will make the Z axis who usually is on top to go down letting Y on top)
You also need to reset the location of every parts to the center (0,0,0), you can use CTRL+A and do reset position.
Now, create a new material for each parts, it will be needed after. (You can name it whatever you like, in this case i named them carbonskinned and front_skinned)
Finally, once this is done, we save the bone position.
Select the bones, go into pose mode, select all bones and do CTRL + A, and select "Apply Pose as Rest Pose"
This part is where it get tricky, mostly the fault of the front wing mesh depending on if the polygons are cool to work with or not.
Select all the parts of the front wing, then the bones in object mode. Do CTRL+P and select "Armature deform With Envelope Weights weights".
If upon doing this the front wing mesh is deformed, smaller, or bigger then revert the changes. Make sure that all parts are unparented, and that their scale is set to 1.0
The bones are now affecting the front wing like it should. But if you move one bone, the effect might not be to your liking.
We now have to fix the "Weight Paint". This tells how much the area of the front wing will be deformed by one bone.
Go into edit mode, and check the Front Wing mesh. What we need is to separate the areas between the bones.
You can use the knife tool to creat new subsection in the mesh.
Sometime the knife tool won't cut certain parts, I'm unsure why but it shouldn't impact much anyway.
Now that this is done, enter into Weight mode, Select a bone in the vertex group, you will see in red the area that will be the most affected by the selected bone when moving. We will change the weight map. Set the Weight to 0, and paint the whole front wing.
Do the same operation for all the objects and the bones, everything must be blue.
Now let's assign each region between the bones correctly, chose one part, go into edit mode, and select the region that we will affect to one bone.
In the vertex menu, make sure weight is set to 1, and select assign.
When we go back in Weight mode and select Bone003 we see that the part is completely red, if some areas inside are not red (because some parts of the wing were not correctly selected, you can fix it with the gradient tool, and swipe from the extremity of the wing to the bone extremity.
The same goes for the area between the bones, select them in edit mode and paint it for bone 2
Do the same for the other side, and the other parts.
Once it is done you can test rotating the bones, the wing should flex normally
If for some reason you see some part bending the wrong way, it means your weight paint is wrong and you should redo it until everything bend normally.
Now we need to animate the front wing bending backward, because as you know, the more speed you have, the more force will be applied to the front wing forcing it to bend backward.
Go into pose mode, and save the default rotation to the frame 1, and for frame 100, make the wing bend backward.
Bone 2 and 6 must be rotated by -2 degrees on the X axis
Bones 3 and 7 must be rotated by -3 degrees on the x axis
And to finish, bend all 4 bones to 2 degrees on Y axis.
Now if you play the animation you will see the wing bending backward from 0 to 100, if the animation is good enough for you, you can export it with the ksanim exporter. Else you can tweak it to your liking.
For now, we will name our ksanim FW_Flex.ksanim
Once this is done, you can export the fbx back to the unpacked car folder, and open KsEditor. You will notice that it has automatically set the shaders to ksSkinnedMesh for the new materials you created and bound to the flexing parts of the car.
KsSkinnedMesh is just the equivalent of KsPerPixelMultiMap but for bones, you also have the KsSkinnedMesh_NMDetaill which is the same as KsPerPixelMultiMap_NMDetaill
Now everything should be done on the car side, if you have some problems like the front wing being misplaced in ks editor, it means you haven't reset the location of the front wing in blender, make sure that location, scale, and rotation is reset back to 0 and that Y axis is pointing to the sky.
Now that we have done the animation, we need to specify to Assetto Corsa how to run it.
We need to create a wing that will be tied to the flexing wing. I have already 8 wing object in my aero so this will be the 9th.
Past this to the aero.ini and save it
This file is where we will specify the ksanim location, which wing it should affect and what frames it should play.
Don't forget to change the animation number if you already have some in your wing_animation.ini
Now we need to specify the bones that will wobble, this is a CSP features which makes the wing move when you hit a kerb or make contact.
Add this to your ext_config.ini inside the extension folder of your car.
We have specified in aero.ini that we use two .lut files : neutral.lut and fw_flexanim.lut, download them and put them in your data folder.
fw_flexanim.lut is used to map frames to a certain speed. You can edit it if you want it to bend faster or slower depending on the speed you're reaching.
You can check that the fw_flex animation works correctly in showroom, and then in game if it wobble.