So I am making a side scroller game, and I am trying to implement something like a grappling hook. This “hook” can only be used on 2 different actors in the level, and they will always be above the pawn (ledges essentially to climb higher). I’ve been trying to use a line trace, but I am having trouble understanding how to make it work in this environment. I’ve followed along with some tut’s, but they involve use of the mouse, or the ability to control the center of the screen to direct the firing of the line trace: A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums. I don’t have this functionality in a side scrolling environment though, as I am making it strictly controller and keyboard based.
Would I have a better chance of using a trigger box instead of a line trace?
I took a look at Swing Ninja, but the way they use the grapple is by cllicking with the mouse (or using touch). Since I am only using the keyboard or a controller, I’m not able to do that. Essentially, when my character is close to a ledge, I need the option to be able to “grapple” to it. Would a trigger box be able to do that? How would I know which ledge to grab? I know I could use Get All Actors of Class, but how does one distinguish between all the different actors found to be able to grab the right one and not go flying to some other part of the level :). Thanks for the replies, the logic for this is just not registering with me.
A trigger box would work, where if your player overlaps it it can set a variable to make firing the grapple enabled.
Or you can a ray trace and if the hit result returns a specific object it also enables grappling.
Perhaps there are even more ways but lets use the 2 examples. Use the ninja logic to do the actual grapple movement.
So we are going to look at how you would go about doing the grapple, not the movement.
Lets assume your platforms have trigger boxes extending down and it has a billboard or any other invisible component that will be used for the location of your grapple point.
On your character you have event on actor begin overlap -> cast to (platform) on success get component grapple point and set a vector variable to the world location of the component and use that point as the grapple point.
The other way is to cast lines in various up directions and break the hit result. If the actor hit result = to your chosen platform get the hit location and use that as your point to grapple to.
Thank you very much for your help!
I’m trying to avoid using trigger boxes as much as possible, that is going to make level design (plus figuring out which platform a trigger box corresponds to) a lot harder. On the ray cast’s, are you saying consistently shoot them out and break the hit? Wouldn’t that incur a lot of run-time? I’m guessing your meaning when the button is pressed?
Alright, using trigger boxes was adding way too much complexity to an extremely simple level, so I decided to go with the line trace route. I’m trying to use a for loop to shoot 8 line traces at various angles around the character. Currently, all 8 shoot at the same place, cause I’m having trouble figuring out how to make the traces stay in line with the character. I know it’s something stupid I’m doing wrong here :), thanks again for all your help.
And this is how I have it setup. I’m not doing anything with the HitResults yet, till I can get the line traces right:
I got the loop and traces working correctly, I got the hit result broken and am able to determine if I hit the right Actor. The problem I am now having is with LaunchCharacter. The results of this node seems to be random (I just don’t know how to use it). I’ve got my actor’s location, and the location of what I want to grapple to, what ritual or contract that needs to be signed in blood do I need to use launch character to launch to a specific point, no matter where my character is? Sorry for my Noobism, I’m starting to pick UE up, but some parts of it I just have trouble making click. One thing that is confusing me is that I am trying to launch the character to a specific point, but launch character wants a velocity. I’ve come close by combining vectors, and that works if I am relatively under the actor, but if I am 45 degrees or lower to being horizontal with it, I just go blasting into the air (I get past the skybox in about 2 seconds (Pretty cool really :D)). Am I using the wrong node to close the distance between 2 points?
Glad you got it working.
As for your character launch issue, i would say this is where the ninja example game comes into play. I havent looked at in some time so cannot comment but i would suggest you derive your method from what they did in that game.
Also check this out. To some degree it sounds almost like your issue.