Grappling hook for 2D game

Hey i want to make a grappling hook for my 2D platformer but im not quite sure how to go about it.

Hi @Orange_Test_Room,

A grappling hook I imagine will involve a number of things coded, like:

  • Player input for direction and power of the throw
  • Triggers/colliders to find out if there is something to grab like an object or surface
  • Act on the grab based on your gameplay.

Do you feel comfortable writing code in Playcanvas? A good place to start learning how base mechanisms like physics, forces, mouse and touch input work by following some of the tutorials and looking through the example project here. Getting some experience on how basic concepts work in code will make it easier to approach this problem.

yes i am comftorable “coding” in playcanvas, well if you even call it code, but the tutorials dont help becuase im lust not sure how i want to do this. all i know is that i need to find away so when a certain key is pressed if the player is near a grapple point a rope will appear. maybe i couls set up a thing that dettects the player and if it does it will check if a key is pressed ex:space then a ropee will apear and connect to the grapple point. maybe i could just enable/disable the rope but what about the keypress and getting it to o to the grapple point

You can use pc.Entity methods to position/rotate and scale your base rope entity to “stretch” from the player towards the grapple point.

Here is useful library that can calculate a more complex trajectory:

1 Like

wow thanks

ok so this is good but the bullets and red line dont coincidde quite right

and i still need the actual rope figured out
maybe we shold use a raycast that looks or certain entitys with the right tag that will then apply forces to make the plater go to that entity

ok so i think i can get it so the player can swing on a rope i just need the shooting thing