Problem aligning character to swinging rope
I am trying to get a character model to climb a rope. The current system i have is almost functioning correctly, but if you climb up and down the rope a few times without dismounting, the character eventually goes out of alignment with the rope, and the hand movement in the animation slowly angles away from the rope until the character is grabbing air.
What i have done is set up a static mesh rope, pivot point at the top. Attached this via a physics constraint component to a static mesh anchor placed just above the rope. The character is animated to move in and jump onto the rope, and this is achieved with a in-place animation in combination with some blueprints to rotate the character towards the rope, then use a lerp/timeline to move the character into place. This aligns the outstretched left had exactly onto the rope. then the characters mesh is attached to the rope static mesh, and force is applied to the rope to make it swing.
This part all seems to be working perfectly, and looks quite good. Once the force is applied, the rope moves around with the mass of the character, and i use a "set world location" node along with a "get up vector" node to move the mesh in the z direction relative to the angle of the mesh, and then i manually move the player controller along with it to keep the camera in place (third person camera).
Theoretically, when the mesh is moved in it's relative z direction (determined by the mesh being attached to the rope), it should move up the rope in a perfectly straight line at whatever angle the rope is on. But it's not quite working out that way. It works well for one or two climbs as i said, but as i move up and down it slowly goes out of alignment.
So does anybody have any ideas how i might go about perfecting this? Or am i going about it in totally the wrong way? I have tried to reorient the mesh every update frame to keep it in position, but this has proved difficult to do with the pivot point located at the top of the rope and the rope being on a variable angle.
instead of assuming the mesh is oriented similar to the rope its attached to, and moving the mesh up relative to itself, you could try moving the mesh towards the pivot of the rope. you could subtract the mesh location from the ropes pivot, to get a vector pointing from mesh to pivot.
if your rope is a chain of bones, and you want to slide along the bone chain regardless of how its bent, then you may want to use a spline component, setting each point to a location on the chain. once you have a spline that matches your bones, you can use GetLocationatDistanceAlongSpline to find locations along the rope.
or maybe, if you are attaching the character to a specific bone along the chain, you can just slide towards the root of that bone, and once you are close, you can attach to that bones parent bone, then slide towards its root.
Follow this question
Once you sign in you will be able to subscribe for any updates here