Phil, good question.
The scripted motor API was added before we had the stepping-up logic, and at that time both motors only had one timescale. The horizontal (H) and vertical (V) timescales were split out to make the stepping-up behavior possible. The particular logic you’re pointing at is effectively an optimization: when the two timescales are identical then it doesn’t make sense to decompose the motor’s velocity and apply the components separately: you’d end up with the same effect as just doing it as one vector but it would cost more CPU cycles.
The only code in the
else case not about computing the motor’s effect is the bit that sets
MyAvatar::_steppingUp to true. The assumption when I wrote it was: only the default motor has asymmetrical H and V timescales, and it is the only thing that needs to know about “stepping up”.
Perhaps we should expose the scripted motor’s H and V timescales to JS? Maybe… but first some overview of the default motor:
The default motor changes the V timescale dynamically: normally it leaves it very long, which makes the vertical component of the motor weak: the avatar descends to the floor, especially after walking off a ledge. However when the avatar encounters a navigable “step” the default motor reduces the V timescale (making its effect kick in faster) and also dynamically adds a V component to the motor, pointing it up even though the “control” signal from the user is: forward.
This “stepping up” adjustment logic is trickier than one might expect and requires correct information at low latency to reduce a “hop” effect at the top of each step. Which means: it is easier to implement in C++ than JS because the C++ has access to the correct data faster. As such, I don’t know how useful it would be to try to make the scripted motor able to handle stepping, unless it was done at the C++, in which case maybe we should expose some of the default motor’s parameters to JS? Maybe we only need one motor (the default one) but give it more JS knobs? Or maybe we need an arbitrary number of JS motors but supply a finite number of types: simple, default, airplane?
I’m interested in enhancing the motor API to make it possible for you to accomplish your goals. Perhaps you could describe what you’re really want to do and we can brainstorm how to get it done, in C++ and/or JS.
Are you trying to speed up the avatar’s walk to be a run? Or are you trying to make a flying jetpack that can “step over” (not get stuck on) low obstacles?