I am trying to develop my first game and learning as i go. I am trying to make a 8-bit(ish) 2D sidescroller where a tilemap is my level.
I am now trying to make some fun weapons, and one of them that im trying to create is a boomerang that should stick to whatever it hits that i can detonate whenever i want.
I have managed to do everything except for the sticking to whatever i hit part.
My plan is to have a check to see what it hits, and just contantly update a “Set world location” node on that thing i have hit. Problem is i have no idea how to do that.
Anyone know how to make a check to see if its an enemy or a wall? What nodes should i use for that?
I have made it now so if i hit anything it sticks to myself. This is how i did that.
You can check the actor that was hit from the Other Actor pin in the Begin Overlap event
Using that you can check, perhaps through a cast or maybe an interface function, to see if it’s one of the target types that it can stick on
After that, you don’t have to manually update the location like you do now, you can simply attach the boomerang to the hit actor (Other Actor) using Attach Actor to Actor/Component, and it should automatically move with the target after that
Thanks for the answer! I will try this so see if i can make it stick to an enemy. I think I have to redo my blueprint a bit couse i have missed it up a little with a parent blueprint destorying actor when it hits enemys.
But what if i want to make it stick to a wall if it hits a wall? What check should i use then? In collision its called world static I think, but i have been trying to see if there is anything like that when casting but can’t really figure what i should use then
Edit:
I think the attach actor to actor might work for the walls as well, I have just made a weird motion with the boomerang using timelines so it updates velocity to keep it moving. I will look if i can cancel the boomerang movement as well to see if i works then
It’s the same logic, if your wall has a parent class, then you can check if the hit actor is a wall
You can use a cast, you can use an interface call, a function CanStickTo for example, which is overridden in your enemy class and wall class to return true, you can use Actor tags (ActorHasTag), there are many ways to go about it
If you have a specific collision channel or object type for stickable objects and have your boomerang only collide with those, then you know that when it hits something it is guaranteed to be stickable, so you can just continue with attaching
There are a few ways, each with its pros and cons, and in the end it’s up to you and what you think is best/more convenient
i will fiddle around with this and see if i can get to to work the way i want. Thank you for all the information, its very helpful Ill get back if i manage to solve it