Like the title states, I am having some serious trouble getting the vector math behind ladders to work exactly how I want it to. I’ll try to be as clear as possible since a video would make it far easier to explain :).
For walking I use the standard +z = forward, +y = up, +x = right as so:
My desired functionality is that when I am on a ladder AD will only translate a player along the ladder’s x-axis, and WS will translate a player along the ladder’s y-axis. So in the following two images, I will only translate along the respective x(red) and y(green) axis for each ladder:
The best I’ve come up with is getting a quat to rotate my desired movement towards the up-axis of the ladder. What this didn’t do, however, is keep my sideways movement locked to the moving along the x-axis of the ladder. Any ideas of how I can get what I want?
Can’t. The whole thing is on a ship that can corkscrew through the level. And for other reasons I can’t have the ship stationary while the rest moves, or show it what’s happening via camera.
No, they can walk as a typical fps character controller. But they need to be able to continue to mouse-look while they’re going up and down on the ladder.
So you want the x-axis of the ladder’s transform to dictate the moving direction when they push left or right (AD), and the ladder’s y-axis dictates the moving direction when the player presses up or down (WS).
something like:
Transform ladderTransform = *a reference to the ladders transform*;
Vector2 input = new Vector2(*AD*, *WS*);
Vector3 desiredMove = ladderTransform.up * input.y + ladderTransform.right * input.x; //multiply by speed if needed
Finally got it. I had to manually map my input directions to the axis of the ladder object in world coordinates, then convert to my player’s local coordinates: