Home Unreal Engine

Can I make this spline sway?

polycounter lvl 5
Offline / Send Message
kwagner polycounter lvl 5
I have this spline blueprint that instances a number of lantern meshes along the spline, and I would like for the whole thing to sway as if in the wind. Is there a way to do this? Using the simple grass wind was suggested, but it wasn't exactly what I was looking for as it only affected the lanterns and not the blueprint as a whole.


Replies

  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Yes. You need to use the world position offset input of the material, but I guess you already figured that out when you tried the grass wind. You were pretty close by trying that. 

    This is how this can work:

    Your asset need to have some sort of a weight map that tells the material which area of the mesh moves, and which doesn't. Imagine a gradient that starts at the beginning of the spline as black, goes white towards the middle, and goes black again at the end of the spline. You can use a texture, UV channel, bounding box, or anything for this. Then, you can multiply that by some very low frequency noise and plug the whole thing into the world position offset.  The noise coordinates also need to have time applied on it, so it pans the noise. The higher frequency noise you use, the more "waves" it will have. You will also need to multiply the whole thing by a vector, which tells the movement direction, and by a scalar, which tells how much to offset at maximum. Like using 100 would mean the fully moving area (middle) would move by 100 units. Hope this helps.
  • kwagner
    Offline / Send Message
    kwagner polycounter lvl 5
    @Obscura

    Doing this in the material isn't going to work as the lanterns and the rope are different materials, and they are instantiated along the spline. Is there a way to get this movement in the blueprint itself either through the construction script or the event graph? I have several of these splines with different numbers of lanterns and rope lengths, so using the world offset node in the materials isn't getting the swinging motion I want. 
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    You can simply add the same world position offset graph to the lamp as well. Then it works. Believe me, this is the way of doing it. Let me know if you can't manage to get the desired result, and then I'll make an example.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Alright here it is:
    https://youtu.be/tjAEcof0RaI


    I simply added the same thing to the lamp material too. The bounding box is the weight, this will work in your case too, as they are one actor. Its also used as the coordinates of the noise, but its made very big, so it distributes a very small area of the noise over the mesh, so it doesn't distort visibly. The transform at the end is used to make it working with rotated actor too (its made to be local y axis relative to the actor)
  • kwagner
    Offline / Send Message
    kwagner polycounter lvl 5
    @Obscura
    Okay So I added that graph to both the rope's material and the lantern's one, but the endpoints of the rope don't move, which is the part I've been having a hard time wrapping my head around figuring out.


  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    It looks like it creates individual bounds for each segment of the spline. This is simple to solve in theory, its a single checkbox. Open your bp, and select the your spline, and on the details panel search for "Use attach parent bounds". After ticking this on, they should have one bound, or at least same sized bounds, and it should work. Let me know what happened, but I believe this will solve it. If it doesn't its possible that you need to tick this on on the node where you add the spline meshes.
  • kwagner
    Offline / Send Message
    kwagner polycounter lvl 5
    @Obscura
    It didn't work. Could it be because my spline is a child of the DefaultSceneRoot? Because I didn't find that checkbox on the spline itself, but it was on the root.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    No. Its on the spline mesh. Select the node where you create the spline mesh components, and enable it on that. Like this:

    If that still won't do it, I'm sorry but yeah this isn't working with spline meshes. In that case, I'm not sure how you should approach this, because this is the standard way otherwise.
  • kwagner
    Offline / Send Message
    kwagner polycounter lvl 5
    @Obscura
    That still didn't work.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Okay. Then sorry, but you can't sway a spline mesh, at least not in a straight forward way. You could use a manual bounding box in the material, so they would actually have the same weight, but this would be painful to work with, and I do not recommend it. The blueprint would need to set up the material parameters for this virtual bound.
  • kwagner
    Offline / Send Message
    kwagner polycounter lvl 5
    @Obscura
    Okay I might be able to work with this as it is though. Thank you so much for all your help though! I really appreciate it!
Sign In or Register to comment.