2D Grappling hook Blueprint [HELP]

Hello, I am a beginner in Unreal Engine and I want to create a grappling hook that pulls the player for my first 2D game. I have watched several videos on YouTube, but unfortunately, they are all directed towards 3D. Therefore, I tried to create something using ChatGPT, but unfortunately, it does not pull the character. I would appreciate your help in guiding me in the right direction.

Imgur

Thank you for your attention.

Hey @Mw1ng0l3! Welcome to the forums!

Real quick- can you explain which parts are not meant to be part of the code? Things like this are confusing when asking this question- if there CAN be a white line and there isn’t one going in, generally it will not do anything at all.

image

One think I will point out- anywhere you see a yellow (vector) pin, you can right click to “break struct pin” and get your X, Y, and Z separated. So what you’ll do with that is you’ll make sure your X or your Y, whichever is your unused one, is set to what it needs to be, and let the other two be what determines your new point. So you’ll use “Make Vector” and plug in your new X Y and Z. :slight_smile:

Hope that helps! Get back to us!

Your set nodes on the upper part are not connected into any execution. They will not run. Your grappling custom event has the attach point as 0, 0, 0 which will always be the origin of the world. I’d recommend you have a different test location than this since it’s a grappling hook. Maybe something higher in the air. Also in your grappling custom event you should set the input “Attach Point” location vector as a variable like ‘TargetAttachPoint’ or something similar.

Thank you for your quick response! I’m not entirely sure which parts of the code should remain as is. I’ve been following tutorials and consulting GPT chat to adapt what was shown in the video to a 2D setting, which led to the current scenario shown in the screenshot. I apologize for the confusion.

Imgur
Imgur

This looks like it should work with minor alterations, as long as your timeline is set up correctly!

t
Hope this helps!

I’m sorry, It didn’t work the result is the same, I does not push himself

Well, darn!

Can you show your code with my updates to it so I can see if there are any errors?
Thanks! :slight_smile:

Yes here it is Update 1 - Album on Imgur

investigated and tried to adapt the Blueprint a bit more, and I ended up with the Blueprint like this. This time, it manages to pull me for some reason, and the lines turn green. I think it’s not working because it doesn’t detect the ground and walls, which is why it’s red? I changed the code - Album on Imgur

I think the reason for this is as I stated above- you need to have your X (or your Y whichever is the one that’s locked) for your mouse traces be set to whatever your character is locked to. Only the Y and Z (or X and Z) need to be changeable- what’s happening is it’s getting the traces either too close or too far away from the camera! :slight_smile:

Pic: They’re all coming toward the camera.

How can I fix it?

I did not read the entire thread, but what are you trying to do again?

  • trace from the character towards the cursor?
  • trace from the camera towards the cursor?

One way or another, check this thread out:

This will work for 3d and 2d but you may need to increase the trace distance if the camera is far away from the character.

1 Like

Hi, Thank you for the reply, I’ve seen your link and I tried to implement based on your comment, but I’m having a hard time can please tell me how can I adapt to my blueprint?

Imgur

Try using the nodes as shown in the thread.

I tried, but it did not work. I also tried stripping down what was happening in the blueprint and came to the conclusion that a few things were not doing much of anything, and I ended up with this:

Could you show the full implementation, as in the thread with line intersection? We can’t see how it was set up and it’s easy to make a mistake.

Of course, here: Imgur: The magic of the Internet

Thank you so much for helping me

The script looks OK.

• how are you calling it?
• are we sure Plane Origin 1,0,0 is correct?
• is 10k trace long enough?
• what result are you getting?

Asking as we have no clue how the scene is set up.