Using AlignOrientation to point characters head toward a rope and make it look towards velocity,

I am working on this rope swinging system to kind of learn the new physics constraints better, and I was trying to use the AlignOrientation constraint to make my player point its head towards the end of the rope, while also looking in the direction of their velocity. I am not very good at vector math, so my result looks like this:


Note that I was not pressing any keys during this, my character just kind of automatically swung itself, and it doesn’t at all do what I had intended. This is the code I used to set the CFrame of the AlignOrientation: (It was set to 1 attachment mode)

AO.CFrame = (CFrame.lookAt(endAttach.WorldPosition, startAttach.WorldPosition) * CFrame.Angles(0, math.pi, 0))

The CFrame of the AlignOrientation was set every heartbeat on the server.
I was hoping someone could help me figure out the correct equation to replicate the effect that I am looking for. Thanks!

2 Likes

First of all, I think you should be doing this on the client to prevent lag.

Second of all, enable rigid mode for debugging so we can see the issue clearly (this might fix it).

1 Like


Yes, you’re right, I should be doing this on the client, but this is mainly for convenience right now as I am just testing.
I enabled rigid mode on the AlignOrientation and not much really changed, if anything the swinging issue got worse. It is not really my main problem though, I am just trying to get help on what the right equation would be to make the AlignOrientation point my characters head to the rope end and face it towards the velocity.

1 Like

Looks like you need to orient the attachment to your desired orientation.

1 Like

Yes. I am aware of that. I’m trying to ask for help with getting the desired orientation.

1 Like

I usually find it by trial and error. Try continuously setting the orientation to different 90-degree increments (like 90,0,0, 180,0,0, 0,90,0, 0,0,-90, etc.)

Now I myt just be being dumb but I didn’t get what the issue was lol. Everything seemed to be working just fine.

AO.CFrame = CFrame.new(Vector3.zero, HumanoidRootPart.AssemblyLinearVelocity)