Hey guys!
Pretty new to this whole blueprint thing, and I was just wondering if someone know how I could run this blueprint in a loop?
What the blueprint does is spawn a static mesh I made, and then it moves it from the right to the left. What I would like it to do is spawn the mesh again after x seconds.
I’m pretty sure this is doable, but I cant figure it out.
Use “Add Local Offset” node instead of your function, it’s much more convenient
Check out this Playlistfrom Epic and this for Blueprint Essentials
For loop use “For Loop” node
A loop for such task would freeze everything else.
For smooth movement or value changes use interpto.
In your case: either destroy your used mesh and then spawn new one in start position. Or simply change location vector of mesh to starting point.
Condition for this could be seconds that passed from spawn, or location it reached (eg, x>20000).
I will definitely check out the youtube videos you linked me to zeOrb, thanks! I’ve tried using the “Add Local Offset” node, but it doesnt quite work with the blueprint (I made a new one btw).
And Nawrot, why the heck havent you told me about interpto before? (aka thanks for pointing out that interpto existed) It made my life a lot easier, in fact I made a new blueprint using interpto to achieve almost the same effect.
My problem now is that I cannot figure out how to asssign a random z value to the spawned location of the mesh. If I try to assign a random z value, the mesh jumps up and down when I play (probably because its getting a random z value every tick, and therefore changing the z value on the fly?) So how would I go about giving it a random z value at the spawning location?
Also I’m gonna try to get more into the loops thing, but at the moment I dont understand much of the forloop etc. But is this new blueprint loopable without freezing everything?
Thanks man! I tried setting up like you did (I had to change some x,y and z values) and it worked, but it didnt move the object from right to left, so I added some modifications, and here is what I came up with.
Its probably just as bad as the 2 first ones I made, but if its allright, would it be possible to run this in a loop, and if so how?
Sorry for such noob questions, new to this. But its still pretty fun to learn while doing these kinds of stuff
To avoid having to get the World Location every time, you could restructure your Components. As the Root component, use the “Scene” option at the very bottom of the add components list. Scene is nothing, just something to use as a fixed point. That way, you only have to set the relative location of your actor using “Set Relative Location”. It saves a few steps.
Also, if your delay is fixed and won’t change, you could use a Timeline to handle the movement. A Timeline can be set to loop automatically. In that case, your blueprint would consist of three nodes; Event Begin Play->Timeline->Set Relative Location
To create a Timeline, add the node (right-click, bottom of the list). Double-click the new node and a Timeline window opens. Click the “V” button to add a vector track. Since you seem to want Y-axis movement only, click the little green checkbox (Y is always green). Next, you’ll add keyframes to set how far the actor will move over a certain amount of time. You can even tweak the curve to make it ease-in or ease-out as the actor “lands” in its final position.
You have two options when it comes to setting up the keyframes: A) You can simply do 0.0 - 1.0 and add a scalar vector to the output of the timeline (allows you to set the distance without editing the timeline), or B) just set the distance directly in the timeline (-3000 in your case). I suggest using the 0.0-1.0 option. To do that, shift-click anywhere on the timeline to add a keyframe. While that keyframe is selected, you can edit its “Time” and “Value”. You want the first to start at 0.0, so the Time is 0.0. Set the Value to 0.0 as well. Shift-click to add a second keyframe and set the time and value both to 1.0. A third keyframe will control your delay. So shift-click again, make the time whatever you want for a delay +1 (taking into account the 1.0 of movement). Finally, at the top of the Timeline window, enable the “Use Last Keyframe” and “Loop” options. You’re with the timeline.
Plug “Event Begin Play” into “Timeline:Play”, Plug “Timeline:Update” into “Set Relative Location”. Drag the variable for the component you’re moving into “Target”. Connect the “Timeline:New Track” output to a “Vector*Vector”, then on to “New Location”. On the multiplier, set Y to -3000. That should do it.