Ledegrabbing by using regions and collision boxes

hankster112

  • Posts: 27
I am attempting to create a ledgegrab mechanic, but I am unsure of the whole process. The way I would like to do it would be to create two 1x1 hitboxes on the player actor and individual 1x1 regions on each tile corner in the scene they can ledgegrab onto. However, actor regions and scene regions seem to be incapable of interacting with each other, unless I'm missing something obvious. There is also the usage of actor collision points, but the block guide and Stencylpedia is not very descriptive of what they are or what they do, i.e. what tile data is and how it should be used. Is there an example of what would go in tile data that could tie into a ledgegrab mechanic?

merrak

  • *
  • Posts: 2738
This is a good candidate for one of the "much harder than it seems at first" problems--particularly, because there's so many little problems that need to be solved:

* Detecting the collision
* Gluing the actor to the ledge
* Suspending actor gravity while the actor is hanging
* Moving the actor during the climb state
* Interrupting the climb if the actor is hit
* Re-enabling gravity when the climb is finished
* Re-establishing on-ground detection when the climb is finished

I can show you my result: It's at the 27:55 mark of this video: https://www.youtube.com/watch?v=AGAYfjXuDLA&feature=youtu.be&t=1673&ab_channel=rlw

As far as how it is implemented--that could be a whole video in of itself.  I'll mention that I found using actors more reliable than collision regions--not to mention, easier to manipulate and view in the scene editor. In my game, the ledges are represented by the green, turned arrows. These actors have a special behavior (Ledge) that just holds some data: which side the player can grab; is it a one-way platform; etc. They are also set to go invisible 'on created', so that I can see them in the scene editor, but not in the game. Moving platforms (like in the video I linked) also have this behavior.


Most of the action takes place in the 'ledge grab' behavior that the player actor has. It's not a simple behavior because it has to handle all of those cases I just listed.

Ledgegrab is actually the simpler of the two problems. Climbing is harder. For ledgegrab, I store the coordinates of the player's hands. When a collision with the ledge actor is detected--and the player is moving into the ledge (holding right or left button as appropriate)--then the actor gravity is disabled and her coordinates set to the (x,y) of the ledge, + (x,y) hand offset. A moving platform will need to adjust the player coordinates every tick as the platform itself moves. Whenever the player lets go, gravity is re-enabled.

The simplest solution might be to look at one of the resource kits available. TheIndieStation has a resource kit with a grab mechanic, but I think it is paid. I don't remember if Luyren has this behavior available in a resource kit, but it's worth looking.

hankster112

  • Posts: 27
Very in-depth and descriptive post, thanks!