I'm currently working on rope Swinging. The Rope consists of Physics Constraints/Joints and between them the rope is rendered.

I would like align my Character's Pitch to the Rope.

I'm horribly bad at vector Math, and I have trouble finding the solution. Here's a picture that shows what I want to achieve:
enter image description here

I tried using the Difference between two joints but somehow it doesn't work.

I'm using Unreal Engine if that helps.


If I understand what you want, you make an object rotate to face a vector with a rotator.

So in this case you want your player's Z (Unreal's up) to face the vector between the two points on the rope it's touching.

So if we get the two nearest points on the rope (p1 and p2 for ex): enter image description here

If we do (p2-p1) and normalize it, we get the direction we want the player to turn.

Then we can use a Rotator to orient the player to that vector. In this case we want to make a Rotator from a known Z axis (The vector we just found).

And then we apply the rotator we get from that on the player.

enter image description here

If you want to set the forward direction too, there's a "Make Rot from ZX" that will try to orient the player to meet those two vectors.

There's a Rotator class with these functions in C++ if you're using that.

(BTW some engines like Unity just let you set the up vector of your player explicitally like "player.transform.up = ropePitch" or something)

(I could also probably explain the math going on in the background but for practical use this is all you need!)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.