How to make a 2D Boomerang Projectile?

Hello,

I’m working on a 2D pixel art platformer for one of my classes, and the main character uses a boomerang to hit obstacles and enemies around walls. The idea is to use a reticle or an arrow to display the arc the boomerang is going to take, and the player can adjust accordingly. The problem is, I don’t know how to make the projectile behave like a boomerang, where it comes back to the character (I also don’t know how to display the arc arrow but that’s less important). I turned the gravity of the projectile to -1, so it goes up into the air, but I have no idea how to make it so that it loops back around, and there really aren’t any good guides on how to do this in the Unreal side scroller format. I’ve heard to try using the homing projectile feature, or to use a mixture of physics and pre-planned flight paths, would either of those do anything? Any help would be really appreciated!

So I recently created a boomerang system and, although it was in 3d, I think the basics still apply.

UE4 has this cool thing called a spline which is basically just a curve that has points on it which you can change dynamically. The high level concept is this:

  1. Add a spline component to your character bp or create a new actor bp that has a spline component in it
  2. When you need to throw the boomerang you will need at least two points on your spline
    • the first point will be your character’s hand (or wherever you want the boomerang to start
    • the second point will be the target you want the boomerang to go to
  3. There is also a checkbox in the spline called “closed loop” that allows you to loop the spline (i.e., make it a continuous circle). That way the boomerang comes back to your player.

The advantage of using a spline is that you can also create a spline mesh with the same points to show the path of the boomerang at any given time. As long as you change the second point of the spline, you can change where the boomerang will go. You can even add a third point on the spline to control how wide you want the boomerang to spin around.


More documentation about splines:


If you want a super in depth tutorial:

Hopefully that makes sense.

Cheers,
mmmmGoodDinner