| Issue 4: | move on multiple axes at once | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Sign in to add a comment
|
What steps will reproduce the problem? 1. Press 'A' and 'W' at the same time. What is the expected output? What do you see instead? Expected: move forward-left. Actual: moves only forward or only left? To be verified that I understood the enhancement request correctly (I'm not sure my "actual" description above is true of current behavior). |
||||||||||||||
,
Oct 29, 2009
OK, found the cause of the problem. You currently *can* move forward and left at the same time, but when you do, forward soon ends up winning at the expense of left. Here's why: on each cycle, when both W and D are pressed: - first forward velocity is increased, then trimmed to fit sqrt(max_velocity^2 - sideways_velocity^2) - then, sideways velocity is increased, then trimmed to fit sqrt(max_velocity^2 - sideways_velocity^2) If that was all there was to it, the two velocities would stay in equilibrium more or less, and whichever one was maxed first, the other wouldn't be able to squeeze in. However, there's also friction, which reduces both forward and sideways velocity on each cycle. After that, forward_velocity gets first crack at taking up the available gap between current velocities and max. So sideways_velocity gets edged out over several frames till it's down to about 1/10 of forward_velocity. How to solve this? Well... We could try some sort of alternating (or random) ordering between accelerating forward and sideways.
Status: Started
|
|||||||||||||||
,
Oct 29, 2009
Alternating or random ordering would have (I think) had the result that whichever velocity was already dominant would stay dominant. I fixed this issue by letting fwd velocity have first crack at increasing whenever abs(fwd vel) < abs(sideways vel). And vice versa. That way, if you're going forward full-tilt (holding down 'W') and you start also pressing 'D', you'll smoothly transition to an even mix of forward and sideways velocity.
Status: Verified
|
|||||||||||||||
|
|
|||||||||||||||