Skewing a static mesh to create railings

Hello, I’m trying to make a railing tool for a project, which allows me to easily place railings in the world. I have built one based on the tool in the content examples, but it’s somewhat limited. The main issue I have is with slopes. I’ve adapted the tool to allow for sloped terrain, but what I can’t do is blend sloped railings with flat ones. Because the tool only rotates and positions the mesh, the ends of the railings are as sloped as the floor, which makes blending like this difficult. I’ve tried a number of ways to get this to work, including spline meshes, but nothing really works to a satisfactory degree.

The only solution I can think is to skew the mesh into the right position, rather than rotate it. This would keep the end points vertical, and allow the railings to join together naturally. Here’s a diagram showing the issue:

Is there a way to controllably skew a mesh? I tried doing it with spline meshes, by changing the end points but keeping the tangents the same, but this didn’t work. Is there a way to skew a static mesh? I know some engines support skewing by a series of scaling and rotating operations, but this doesn’t seem to apply to Unreal.

No combination of rotation and scaling can give the effect of screwing (shearing), which is a mathematical truth. The problem is whether they provide some way to do the shearing? I even computed the transformation matrix myself and using c++ to apply that matrix, but still it seems there were some hard coded thing preventing any shearing from happening despite that my matrix is supposed to do the shearing. I am not sure if I missed something but this is surely some feature wildly needed.

Sorry ignore the first sentence of my previous comment. It might be possible to combine scalings and rotations to do the shearing. But still, that should give the same transformation matrix as the one for the shearing. Therefore I am not really sure if it can work or not.

Actually you can do it by rotating and scaling if you offset the rotation of your local pivot by 45 degrees. With your local pivot being diagonal scaling will skew the object. You’ll have to use the opposing axis to keep the height correct. You won’t be able to scale the length of your railing anymore and you will need to detach the post or it will get skewed as well.