Fishery : Steering in 3D Part 2
February 12, 2017
Last time I mentioned a problem with up-vector orientation. What I mean by this is when the avatar’s up vector is no longer aligned with the world’s up vector (0,1,0). This can happen easily as he twists and turns through complex maneuvers, winding up upside down or somewhere near it. It creates problems with both the camera and controls.
Because the steering is relative to the avatar’s forward vector (as opposed to the camera’s forward vector), an upside down avatar will have reversed steering. What’s worse is when the avatar gets into some in between orientations and keep changing with each tick as the player holds down the same steering input. The resulting disorienting effect is like that of watching an astronaut in free spin in space. It’s horrible and stressful as a player to experience.
Well, then, one might ask, “Why not just match the camera’s up vector with that of the avatar’s?” That way the controls will be aligned with the avatar’s orientation. But this creates another disorienting effect, where the world is spinning around you furiously, and reorienting your avatar becomes a huge task when trying to navigate anywhere on the map. The player would be constantly battling with the controls to orient his avatar (and also battling the urge to vomit). We would also lose a lot of those smooth camera transitions that I wanted so much in the beginning, leaving us back in a very rigid, tunneling line of vision.
The solution I’ve enjoyed so far is to keep the avatar’s up vector aligned with the world’s up vector as much as possible. We’d in essence be doing all the battling on the player’s behalf without them noticing. Up will always be up, the seabed always below. And so, steering will always move the avatar in the direction that the player has gotten used to.
When and how to re-orient the avatar’s up-vector turned out to be relatively straightforward. Whenever the avatar’s up vector is pointing downward, we’ll trigger a re-orienting animation where input controls are suspended until the animation (and camera recovery) are complete. Whenever the avatar performs horizontal steering, we’ll re-orient on every tick. Whenever the avatar gets into a vertical loop, we avoid triggering any re-orienting and allow the camera to stare at the middle of the loop – up-vector orientation still intact.
Henry Ho