I was wondering if anyone could help me figure out how to make a boomerang for a 2D sidescrolling game. I’ve tried looking on YouTube for tutorials but I haven’t been able to find anything. Basically, I want to make a boomerang that when thrown travels in a straight line for a short distance before it turns around & returns to the player. I also feel I should clarify that when I say “return” to the player I mean that the boomerang that will home in on the player’s location. For example, if the player throws the boomerang and then jumps up onto a platform the boomerang will then travel upwards to the player on the return trip.
I have anything else ready, I have the character’s throwing action all set-up and I have two sets of various character animations for both the character holding/not holding a boomerang. At this point, I’m pretty much just missing the boomerang itself being thrown.
it would help to know more specifically what you’re missing.
what i’d do is in the boomerang add the movement logic.
you could try a movement component and add a couple of positions.
or you can do it manually.
with the movement component you could:
when launched, calculate the end point, set it on the movement component and activate it.
then when the movement component is finished. calculate the return position and re-activate it.
though if the player moves while the bo…ng is returning, you’ll have some issues. either making the b…g change its destination (will look magical) or something else.
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.
Make some variables (boolean) - ThrownBoomerang? , Facing RIght? (Which I assume you work out where to set that one, optional is “DisableAll?”
First check that ThrownBoomerang is false
Set ThrownBoomerang to True
Optional - set Disable all to true
Play your throw montage
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.
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
Cast to your player character and get a ref. Or not, and cast again later for absolutely no reason at all!
Check if your character is Facing Right? This will determine one of two different Timeline driven pathways.
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.
Add two add actor world offsets, split struct the pin and plug each respective timeline into the Y.
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.
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).
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…
Thank you so much for this! I greatly appreciate the effort but unfortunately I haven’t been able to implement your solution due to a major issue.
You see your solution is based on the boomerang spawning out of thin air which is a problem for me because the boomerang in my project is basically a part of the thrower. The boomerang is always visible at all times due to the thrower carrying it with them in all of the animations I’ve made so far. So I need the boomerang to detach from the character’s hand when thrown rather than spawning out of nowhere.
I’ve tried to see if I could implement your solution in a modified manner to work with my current setup but I haven’t had much luck. When I try to detach the boomerang from the character, the boomerang disappears. On top of that problem, I also can’t figure out how to make boomerang move as I can’t attach the boomerang as a target to the AddActorWorldOffset node. Instead the player character ends being the target by default and ends up being hurtled forward as a result.
Yeah, you can use the same boomerang. That method will involve detaches and carefully timed use of delay to let it go from the hand and look right. I essentially copied the boomerang bp, stripped out the rotating movement component and copied its logic and disconnected it from fire. Tried to apply the same logic in the character bp. In your Event Begin play, spawn the boomerang, and attach it (preferably to a boomerang socket in the right hand). After you spawn it promote its output to a variable / OBJ. However you normally throw it, this is where the copied logic from its actor bp comes in and tries to simulate threw detach and attach what that other bp was doing. I used a set timer to simulate a fast firing event tick because in this bp my event tick was in another country. I had to choose .001 for its rate else it did not look smooth, but it would look as smooth as before with an event tick.