Blueprint problem - Throwing Weapon

The horizontal arc of the weapon changes based on player rotation. It should be the same arc regardless of the player’s position or rotation but I can’t get it to work independent of player rotation.

link:http://www.youtube.com/watch?v=KSJzBBQk7EU&feature=youtu.be

The first throws I made before moving my character were the intended weapon arcs

https://rocket.unrealengine.com/storage/attachments/1282-rotationissue.jpg

Im curious, why did you decide against using tick for this?

I’m not entirely sure what you mean - are you referring to an Event ReceiveTick? I’m only wanting this calculation to happen when someone throws the weapon so I hooked it into a custom event.

Yes and you can do the exactly same thing in tick and doing a physics update there. Im just wondering why you opted to use timelines when some simple trig from the moment spawning of the weapon takes place to the moment its destroyed would achieve similar results with less confusion.

Its no biggy, I just found it harder to read because the values are on the graph.

I think I’ve narrowed my problem down to something a lot more definable and hopefully easier to solve:

I have a single timeline that handles blade movement to the most distant location and back (A to B then B to A). A is my player pawn’s location and B is an arbitrary float value (500.0 in this case). I lerp the player position with the (player position + 500.0) using the timeline to get my forward and backward motion. This works well - the blade moves 500 units outward from the player’s location then comes back to the player’s current location. Exactly what we want.

I then try to apply the same logic to my left/right motion. If I take the same timeline arc and the same max distance variable and plug it into the horizontal axis it should give me a perfectly round boomerang arc.

It does – as long as I’m facing forward. I understand that my problem is that my trajectory logic is based off of player Location and doesn’t take into effect the player’s forward direction. I’ve tried so many different combinations of Get Player Pawn → Get Actor Rotation → Get Forward Vector that my head is now spinning.

I can’t seem to find a way to factor in the player’s current direction. Get Forward Vector seems to return a dot product of some sort (a value between -1 and 1 depending on the character’s direction) but my mind is blanking on how to apply that value to my horizontal lerp.

There are a lot of possible approaches. One would be to add an event track, such that an event when the blade reaches its farthest point swaps out the Lerp A target. So you’d Lerp out from one point, then the swap happens, so you Lerp back to the player. Could be done using a Branch node and setting a Boolean in your Timeline.

Just a thought.

Okay, I see what you’re trying to do, but I might suggest going about it a different way. Granted, this is a fairly limiting view of your overall approach, so I’m interpolating a bit (read: making assumptions).

I would separate the concepts of rotation and velocity a bit further. Your “arcing” or boomerang-style motion is really more about location than rotation. For instance, if your blade went straight out to a point and back on its X-Axis, but moved in positive Y on the way out and then to negative Y on the way back, you get that arc. Therefore, my blade would use a Component hierarchy (parent the mesh component to something like an Arrow) where the arrow handled all the location adjustment.

So let’s just focus on that for a moment.

The moment the blade is thrown, you need to lock down two things and store them in vector variables: the start point of the throw and the end point (that’s the most distant location, not the return point!).

I think you’re getting these from components on the character (which is probably what I’d do, at least for starters) using something like Arrow Components. So you’re basically having to send those locations over to the BladeBP and they get calculated first thing. You need them calculated prior to the Timeline updates because they’ll need to remain constant. If you update them throughout flight, the blade will move with you in a fairly unrealistic manner (maybe you want that??). I would do that on the way back.

So you lock down those two positions, then use a Timeline to Lerp location from the start point to the end point. On Finished, you switch to a second Timeline that Lerps on the way back, but this time the B point (target) of the lerp is the player. In this way, you get that “Zelda boomerang style” style motion that flies toward a locked point, but then flies back to you.

Spinning the blade can be separated, because we handled motion off a helper (Arrow) component, to which the blade is parented. We can just offset the Mesh’s location/rotation from that parent and get any kind of rotation we’d like.

I realize this is a lot to play with. So I’d start by making a simple blade that went to a world position and back. Then start layering on the tracking behavior to make it return to you, then start layering on the arc, then the spin.

Thanks for taking the time to answer this problem in detail.

I’ve already tried a solution where I used a timeline out / timeline back approach and there was almost a full second delay between timeline out’s “finished” and timeline back’s “start”, and the blade would hover for that time before coming back…

I couldn’t figure out why because there was no delay in the timeline and there wasn’t any nodes in between the two timelines (they were hooked directly into each other)

I also used an event on timeline 1 to fire timeline 2 and tried setting the event to like 90% of timeline 1’s length and it just cuts it off so I’d either hover for a second or my arc would be cut off prematurely.