How to make a boomerang for a 2D sidescrolling game?

My understanding is that you already have animation and logic for the throw. But you wanted the boomerang to come back to the character after it travels in a straight line, Y + or Y - in side scroller sense.

The way I achieved this…

In your character bp -

Make some variables (boolean) - ThrownBoomerang? , Facing RIght? (Which I assume you work out where to set that one, optional is “DisableAll?”

  1. First check that ThrownBoomerang is false

  2. Set ThrownBoomerang to True

  3. Optional - set Disable all to true

  4. Play your throw montage

  5. The delay here is for optional adjustments along with the height adjustments on spawn to make it “look” right. Also set disable all to false off the completed of the animation montage.

  6. Spawn your Boomerang actor bp

In your Boomerang actor bp -
Add a rotating movement component, I set it to - 500 on the Y in the video

That number is the speed the boomerang will rotate, for the other direction just reverse it. - or +

  1. Off of an Event Begin Play - Spawn the sound and get a ref to it - https://file.io/2qCCZ8VgkY1w

  2. Cast to your player character and get a ref. Or not, and cast again later for absolutely no reason at all!

  3. Check if your character is Facing Right? This will determine one of two different Timeline driven pathways.

  4. Add two timelines, I will open one of them ( the top one) and show you the values in the vid. Essentially, the bottom one will be mirror opposite values, in this case on the Y. This is so the boomerang does not come to a halt instantly. And these value and curve can be messed with for better results. This is just what I come up with quick. You will add a float track, and the length is going to be how far out you want the boomerang to go before the return action.

  1. Add two add actor world offsets, split struct the pin and plug each respective timeline into the Y.

  2. Bottom half of pic, off the Event Tick, get your character ref (suggest making it a validated get) or cast again just because you can and stuff.

  3. Here I used a gate that starts closed, but you could use a boolean instead. Essentially this gate is going to open when our timeline’s have finished off their complete output(s).

  4. Add actor world offset, here I added on the Zed to make it look like returns to the hand or head.

9, Check if the boomerang mesh is overlapping with the player character mesh, and if it is…

  1. Set ThrownBoomerang? to False

  2. Stop the sound

  3. Destroy Actor

2 Likes