We call this cute little thing the Grabber. It’s able to fire it’s claw at a distance and grab onto things. A clever player might lure it into pulling a lever that is out of reach, or fuse it with a Controller (a robot that enables a fusion to be controlled by the player) and hookshot over a chasm.
One thing about this robot that we knew would be a challenge when we designed it is it’s ability to fire the claw around corners by bouncing it off a Shield robot’s shield. This meant having the chain bend around corners in the environment. Mathias, another member of the team had already done some great work on creating a path for the chain that wraps around environment geometry and I took over where he left off, putting it to use in the game.
The path starts out as a line between two points, one fixed and the other attached to the moving claw. We call these points rope points. Whenever the claw hits a shield, it’s direction of travel is reflected in the normal of the shield’s surface and a new rope point is inserted just behind the frontmost point (the one with the claw) and positioned at the point of impact.
All rope points except for the first and last are constantly moving toward a position right in the middle of the points before and after it, tightening the path. The wrapping path is found by sphere-casting between each consecutive rope point every frame. If a hit is detected, a new rope point is created at the hit position.
In order to create the chain’s visual representation, I used Curvy, a plugin for unity that allows us to place meshes along a spline that we’ve previously used to create minecarts tracks. By creating a spline out of the rope points and placing instances of chain links along it, I was able to create a nice looking chain.
Originally, the chain would tighten as the claw moved through the air, but after some testing I decided to change this so that the tightening would not begin until the claw starts retracting. Hopefully, this will give the player a better understanding of the path that the claw travels when it bounces off a shield.