Dynamic Rope/Cable System for UE4
A fully dynamic Rope/Cable System developed for UE4
This plugin has been depricated. See this page for the new version: VICO Dynamics
This whole thing started after WWE 2K15 came out. Dave and I really liked the rope system they implemented which properly reacted to collisions and physical forces and made the ring feel dynamic and lively. At the time, the ropes in the AAW3 Arena were simple Skeletal Meshes with animations that played on cues to bounce and stretch. But if anything clipped them, nothing happened.
I remembered that UE4 had a plugin built in called the CableComponent made by James Golding, which modeled the physics of a cable using Verlet Integration with proper procedural rendering. It looked great, but that system lacked any kind of interaction with other Actors in a Level. It essentially only simulated gravity and sway when the end points were moved. I began my implementation by using the CableComponent as a reference to completely rework and re-implement the system with the features we need for AAW3.
The first thing I set out to figure out was a way to link the internal Verlet Integration that the Rope Particles are using for Physics with the Rigid Body physics from PhysX. My first goal was to setup Static Collision; I defined this as the rope colliding with a non-simulating blocking RigidBody.
I created an array of Body Instances that accompanied the array of Rope Particles to act as a representation of the Rope Particles in the PhysX Scene. From here I had accidentally achieved one-way collision, simulating Actors now collided with the Rope as if it was Kinematic. This was great but not exactly what I was trying to achieve. I then decided to implement Position Projection which would do a sweep from the old Position to the new Position and check for hits or if we are already penetrating a Rigid Body. It would then correct the End Position to compensate for the Hit. Or if already penetrating, it would project the new position based on the Penetration vector to put the Particle outside of the Rigid Body. This gave nearly perfect results where the rope would now properly conform to the shape of the Colliding Rigid Body.
After getting Static Collision working the next goal was to have the rope interact with other simulating Rigid Bodies. I defined this as Dynamic Collision.
The first approach I tried was to "transfer" the forces on the Ropes Body Instances to their associated Rope Particles and have Verlet Integration take care of the rest. But this led to instability and a number of simulation errors. I then decided to isolate the Hit Impacts on a per Particle basis and later integrate them inside the Verlet phase. Using this, I listened to Hit events in the Rope component and during a Hit that had a non-zero Impulse; I first calculated the impact force based on Mass of the two bodies, the Restitution of the bodies and Impact strength. This was then recorded into the HitForce array for that Particle and a certain amount of energy was returned to the body that hit the rope. This simulated loss of energy during the impact.
The result was pretty darn good considering the amount of rerouting of forces that occurs.
The last major feature that we needed was the ability to turn off the Physics of the Rope and have it fallow a Skeletal Mesh animation. This is a feature specific to AAW3 where we have instances that a certain Move requires complex rope movement and timing. For this I created the SkinnedRopeComponent which inherits RopeComponent and internally runs a SkeletelMeshComponent which is used to Play the Animation and get the Bone transforms. Currently the component assumes the bones are setup as a rope/cable and are in-order. During a Tick, it extract the bone transform and applies it only if the associated Rope Particle is Fixed (not being Simulated). This means that only part of the rope can be animated and the rest can be simulated.
Updates to this plugin will be regular since this plugin is being used in AAW3 and features will also be added from user feedback.