Technical Difficulties with Spaceship Barrel Roll


I’ve been trying to implement a barrel roll dodge into the Flying Pawn BP in the Flying Template example project for a space-themed game I’m working on, which seemed like it would be fairly easy to do, but has proven to be pretty difficult for me.

What’s happening is that when the barrel roll is initiated, it seems like the ship spazzes out, but when I was working on the same project on a slightly slower computer, I was able to see that what was actually happening was that the ship was doing exactly what I wanted; however, it was snapping back to its original, upright position every other frame or so, making it look really bad.

What I’ve done so far, other than just tweaking a million settings without any results, is create a new pawn-class BP and carefully analyze chunks of the Flying Pawn BP as I copy them over to my new blueprint. The result is the same as before, so I’m worried that the problem lies in the C++ code, which I have no real experience with.

Here’s a screenshot of the barrel roll section of my BP (the alpha used for the lerp is a timeline that goes from zero to one):

Context: What leads up to the section pictured is a double tap ‘D’ function to initiate the roll, and then a function for the strafe maneuver using the world location and right vector of the ship.

If anyone needs any other screenshots or information, let me know. Any help would be greatly appreciated!

This is actually my first time posting on the UE Answerhub, or any forum really, so I’m sorry if I noob it all up.

That is weird. Try changing the alpha input with world second delta. Just guessing.

Also, you are snapping to 0,0,0 rotation after delay. You should try to level out the plane like in the flying template. But, I don’t know your project so just a friendly advice.

Welcome to answerhub :smiley:

Cool, I’ll try that when I get back home. And yeah, you’re right about the leveling out thing, I just forced it to 0 rotation as a quick fix to another problem, haha.

Thanks for the answer and the welcome! I’ll let you know what happens when I make those adjustments.

The alpha should never be connected to Delta Seconds because the Alpha is supposed to start at 0 and go to 1. This can be achieved with a Timeline

So when plugged in World Delta Seconds, it just wiggled back and forth, but still seemed like it was snapping back to zero rotation every other frame or so.

The only answer I can really think of is that its somewhere in the code of the pawn class or something like that, unless I’m missing something.

Yeah, I’m already using a timeline

I know. That is why I said it is weird. I tried to replicate it via flying template and my ship too did rotate like many times in 1 second via timeline from 0 to 1. (Assuming it is the spazing that alexundr is talking about) But weirdly when i put the delta seconds in the alpha It did only 1 rotation like supposed too. It was not perfect, but it did it and I was left with scraping my head.

Can you please provide us with the entire code related to this ? If you haven’t figured it out yet ?

Now, I’m also no expert. Just trying to help.

EDIT - I guess, I see your problem. I’m also still guessing since we don’t have a full code.
I think what is causing the weird spassing is you possibly attaching the delay and SetRotation to 0,0,0 with the Update node of your timeline ? Since it is updating every tick the ship is spassing.
If this is the case, try attaching the Delay + Setting rotation to 0,0,0 to Finished node of your timeline.

Strange. I’ll try both of your suggestions and let you know. I’ll also post the rest of my code attached to the problem, though it might take a few pictures

Here’s part one.

And Two.

Then it goes into the initial screenshot I posted.

So, I tried hooking up the delay and set rotation nodes up to the finished output of the timeline. It made me realize that it really was the cause of the snapping back to zero rotation every frame. I can’t believe I didn’t catch that, haha.

But it brought back the problem I was having before, with the ship seeming like it was spinning a whole bunch of times, instead of doing it just once.

Though, I don’t really understand why adding that delay and rotation nodes would stop that crazy rotation from happening and get it to behave correctly, besides the crazy snapping to zero thing.

I tried the world delta seconds alpha without resetting the rotation, and, like you said, it really did slow it down a lot, but it’s still rotating too much, and ends at a random awkward angle that just gets worse each time I roll. Additionally, it’s rotating around a weird pivot point, even though I know the pivot of my ships’ mesh is in the correct spot, which is really weird considering that I’m pretty sure the rotations pivot was fine when some other methods are used.

Man, this problem is so ridiculous. I feel like it’s so close, but it just doesn’t want to work!
I really appreciate all your help on this!

Try deleting the Lerp, leaving everything else the same, and taking what you had plugged into the B of the Lerp straight into the set world location.

I just tried your recommendation, and it just doesn’t show any sign of rotating. I think it just sets the rotation to 360 from where it was at, instead of gradually turning until it’s done.

I’m sorry, were you having issues with the rotation, location, or both?

For the rotation, I would also delete the Lerp. If you know how long your timeline is, I would just add some degrees for every frame of the timeline. So if your timeline is 2 seconds long, you would take 360 / 2 * (delta seconds) and add that to the roll rotation.

The problem is the rotation. Even though I have it set to rotate one time, 360 degrees from where it’s at, it seems like it just rotates like crazy and ends up with some random rotation.

Before, I had a delay followed by a set rotation to 0,0,0 at the end of my timeline update output, in order to combat the weird leftover rotation, and that actually fixed all the problems I was having, but left me with a new one. It would do it every tick, leaving it to look like it was snapping back to zero rotation every other frame or so.

Smart, I’ll try that

Alright, so it’s only rotating once now, which is awesome, but for some reason, it’s going slightly past the 360 degree mark. Also, I don’t have any clue why, but the rotation pivot looks like it’s on the tip of the left wing of my ship.

Give me a second. I think I have a better solution for the rotation. I’ll post a pic here shortly.