Instead of the objects forming in a line, I want them to curve upward. I have been searching but I can’t seem to find an answer. Is there an efficient way to do this in Unreal, or is something that should be done in Blender?
If any clarification is needed on this question, please let me know.
If you needed the arrows to bend & twist along the curvature, you’d need to ensure each arrow mesh has enough geometry to deform and treat it as spline mesh component.
Hi, thanks for this! I’ve mostly put this blueprint and I have some questions, if that’s okay:
How did you ‘convert’ the component to a float (I’m referring to what is in the screenshot)? I can’t seem to figure out how to do this; and
How do you ensure that the Spline references the arrow shape? I currently have an Arrow Actor Blueprint, which sets the material of the Arrow mesh and incorporates a bouncing animation. Will my Spline need to reference a mesh, rather than an Actor Blueprint?
Please let me know if clarification is needed on these questions. Thanks again for the help!
How did you ‘convert’ the component to
a float (I’m referring to what is in
the screenshot)?
Not a conversion, it’s one of the Spline Component’s properties. No matter the length of the spline (physical distance), the duration can be normalised to a set value: 1 by default. A spline that is 5456 uus long can still have a duration of 1 - makes it easier to conceptualise percentage ratios.
Drag the Spline Component to the graph, drag a wire from its reference and then search - you’ll get filtered, context sensitive results. Essentially, all actions that are valid for this graph.
How do you ensure that the Spline
references the arrow shape?
Here I’m adding an Arrow Component - it’s just a debug arrow helping visualise things. You have snazzy looking static mesh arrows, you should definitely use those! As in:
If you needed each arrow to be a separate actor (because it has complex enough behaviour of its own), that’s fine too. Rather than adding simple static meshes, you can Spawn Actors from Class and position them on the spline. Think of the spline as a controller managing other actors’ initial position (which can be later updated run-time).
A note here, one can no longer Spawn Actors in the Construction Script directly. Spawning needs be wrapped in a function first and then executed in the CS. Or use the Begin Play event instead.
I currently have an Arrow Actor
Blueprint, which sets the material of
the Arrow mesh and incorporates a
bouncing animation. Will my Spline
need to reference a mesh, rather than
an Actor Blueprint?
Up to you, really. If each arrow needs to have a life of its own, an actor might be necessary. For the above, if that’s all what’s needed - the spline actor can probably manage that by stepping through all the static mesh components.
That is excellent, thanks for this. I have made some more progress based on your instructions.
I have encountered two issues, which are outlined below.
When I make changes to the Spline (such as adding more arrows or changing my spline curve), the Actors tend to ‘duplicate’. I have attached a screenshot of the issue and the code.
When I curve the spline, the arrows do not keep the similar direction, like in the sample .gif you attached earlier. A screenshot is also attached of this (including the ‘duplicating’ issue).
Do you know what I’m doing wrong that is causing this?
Here’s the thing. What you call a Mesh here is not really a mesh, it’s an Actor. The spline is creating Static Mesh Components and sends them to that target actor. That actor becomes the parent of the meshes and they can no longer be destroyed by the Construction Script of the spline actor.
If the goal is to use just static mesh components for arrows:
in the spline actor, create a variable of Static Mesh type and flag it as Instance Editable
after adding a static mesh component, set its static mesh to that variable
Thanks again, mate - I am getting success with this! It’s looking great.
I actually do want to use an Actor rather than a Mesh (apologies for the confusion in my mislabelling). The reason I want to use an Actor for the arrows is because the Actor has a code in it that makes the arrow bounce up and down.
Is there a way to make the arrows come from an Actor and still keep the same spline functionality as if it were calling the arrow mesh (which keeps the arrows facing the right direction and with the ability to be ‘destroyed’ by the construction script)? If not, I’d imagine I can just copy and paste the ‘bounce’ code into the Spline blueprint.
To be honest, spawning actors with the Construction Script is asking for trouble. The engine explicitly asks you not to. There are workarounds / hacks but they’re usually not worth the fuss in the long run.
If you can get away with creating components only, absolutely do so. I can chip in with helping implementing an animation of multiple elements driven by a single timeline or tick.
From the performance and the memory footprint point of view, 12 static mesh components is much more elegant than 12 actors, especially as far as Ticking is concerned.
Cool, thanks for clarifying that - you’ve saved me lots of time of trying to spawn actors and make it work. If the engine asks us not to do that, I’m going to leave it alone.
I’ve tried to animate the Spline via the EventGraph (code attached). You will probably notice this right away: The code animates my spline, but not the meshes attached to the spline. I cannot seem to figure out how to animate the meshes rather than a spline, and I’m wondering if it’s maybe not possible with the way I am trying to do it.
Can I please take you up on your offer to help implement the animation for this? Feel free to chuck a tutorial video or documentation my way - I’m conscious of the fact that you’ve spent a fair bit of time helping me out already.
Thanks again for all the help. You’ve also well and truly answered my initial question, so I’ll mark this question as answered.
Do note how the components are now added to a Static Mesh Component array so we can keep track of them. This allows me to preview the result in the world and manipulate the spline any way I need:
The arrows are not aware they’re attached to a spline, they will not follow it. The Construction Scripts actually executes every frame and recreates everything from scratch, creating the illusion that objects are attached!
Instead, we animate a spline point and ask the array to update the position of its elements:
Seeing where this might be going, I wonder if it wouldn’t be better to use Spline Mesh Components for this. It’d probably make things more efficient since they naturally mesh (ehm) with splines.
Perhaps you could briefly demonstrate what’s the end goal here is. As in, what purpose will these serve and what functionality is required.
However, what you have done looks super cool and I’d like to know how to do that too.
I have tried to follow along with the screenshots you have posted and I have gotten a bit lost/ran into some issues (probably just because I’m new to Unreal and I’m still getting used to how it all works). May I please have the Blueprint file that you have made so I can analyse it? That would be very useful and I’m curious to see how you’ve achieved this.
Hey Everynone, I’m not sure if this will give you a notification or anything - I was just hoping to follow up on my previous message. Is it alright if I get the Blueprint file that you have made for analysing? I think that if I can see exactly what you’ve done, I can modify it to get what I’m trying to achieve.
Please let me know if any clarification is needed.
I did not save it. I just have the very basic arrow thing from the very first pic. Sorry.
But 100% of the script is in the last 2 screenshots. It’s all in the same blueprint, in the same graph. The Create Arrows custom event is called in the Construction Script.
Thanks for this! This has resolved everything. I tried to go through your points with my original blueprint, but I still failed so I downloaded your Blueprint and changed parameters with my meshes - it works a treat!
EDIT: I think it’s because when I tried to add more points to the spline, UE crashed. So I downloaded your Blueprint.
Also, I modified the blueprint to get the ‘bounce’ that I was originally looking for. In case anyone is interested, I have uploaded a screenshot of the modified section of the blueprint that achieved this (it’s probably not the cleanest way of doing it, but it works).
The wiggle effect is really cool, however, and I think I’m going to use it and play around with it as well.
Thanks, Everynone, for all the help on this! It has been very useful and is appreciated.