Friday, 16 January 2015

Beginning The Grappling - The Rope




Probably the most unique mechanic of the game is the grappling. It drives most of the gameplay and is the core element of the game. After working on the base movement and getting it to a workable stage, I have now started work on the grappling mechanics of the game.

The first stage of making the entire system is to set up a rope simulation. To achieve this, I simply modeled a cylinder, attached some bones to it and did a simple skin.


With the skinned rope, I then took it over to Unity to begin constructing the rope. The way I figured to do the rope was like so:

For each joint in the rope, add a physics hinge in Unity at the same place, and link it to the previous hinge. Doing this x amount (no finished number yet, there's 50 hinges currently) of times manually is time consuming so  I wrote a little editor tool that automates this process for me:

 It's fairly simple, you select the root bone and the grapple hook itself and the script will place hinges at each bone joint and also the hook itself.

 An initial problem I ran into when using the hinge joints was the sheer amount of them connected to together caused the physics engine to break and the hinges to act more like springs than hinges. To overcome this problem, I found about about configurable joints. Think of these as the base for every possible joint that can be used in Unity. The configurable joints exposes all parameters used to configure any joint. With these parameters, I managed to configure the joints to be more stable. On top of this, I also upped the physics iteration count for each configurable joint which provides a more stable simulation.

After this, I could then move on to the next stage of the grappling. The system links each bone joint to its partnered physics joint and then updates the bones position and rotation based on the hinges new position and rotation. After adding a collider to each joint, this is the physics side of the rope sorted. The settings on the joints are not final and I shall tweak them later on, but for now they are fine. This is what a section of the rope looks like:




0 comments:

Post a Comment