-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the character controller to allow walking and jumping #277
Conversation
d3036d2
to
bae56f2
Compare
bae56f2
to
611d445
Compare
Besides the things I've inevitably missed, there are a few changes that I know are needed before this PR is merged, but limits in my own level of experience and sense of good code structure mean that I will need feedback before I make these changes:
The character controller is definitely not perfect. The most glaring issue is that walking into an obtuse wall corner will result in some shaking. However, this is expected behavior, and fixing this I believe should be outside the scope of this PR. In addition, the necessary input lag when jumping means that some coyote time would likely be a good idea, but I also consider that out of scope. I believe the most important aspects of the character controller are as follows:
Most other aspects would likely have a lower priority than adding other essential features to this game, like block manipulation and saving/loading. |
To better playtest the character controller, I created a temporary branch on my fork with block placing/breaking: https://github.com/patowen/hypermine/tree/collision-wip-block-placing-temp. As of the writing of this comment, the character controller code between this branch and that branch are identical, and the only difference is that the |
Could we simplify this to always rotating around whatever axis produces the minimum rotation?
Strong agree. In an ideal world where we fully understand how to factor everything, I'd expect sim.rs to contain only the most trivial logic, instead mainly dispatching to other modules.
That seems fine.
SGTM. |
I didn't go this route because the math is more complicated, and I don't think it's any better for the player. One case to consider is the fact that a rotation about the look-axis (roll) is less jarring than a rotation about a perpendicular axis, since the object the player is looking at stays fixed. A roll is almost always ideal, and the main exception is when the camera is close enough to vertical that it's no longer obvious which way is right-way up, since then, the correction starts to feel random. That's when yaw and/or pitch becomes nicer. For a concrete example, if the player is facing forward but is upside-down, I believe the right move is to turn it 180 degrees to make the player right-way-up, but one can reach a valid orientation by having it face straight up or straight down instead, which is only a 90 degree rotation. All your other suggestions seem good to me, and I should get a chance to address them soon. |
546c43b
to
9885ca3
Compare
I am getting some "WARN Unsatisfied existing bound is parallel to new bound. Is the character squeezed between two walls?" messages (a warning I added for an edge case that should ideally be rare). I'm not sure whether my latest changes on July 4th caused them or whether it was the case before then, but when I have more time, I should be able to find the root cause. EDIT: This seems to be caused by EDIT2: I believe the main source of error here is now resolved. The EDIT3: My next plan is to enhance the Step (1) is necessary because if a temporary bound is added but isn't already fulfilled, unless it's applied directly, it can cause weird interactions with the bound actually being applied. Step (2) is necessary to ensure EDIT4: Step (1) is now done. As for step (2), I don't think that should be in this PR, as adding a cap like this for floating point precision could easily hide actual logic errors like the one I found initially. I believe the concern I found in this PR comment has finally been resolved. |
9885ca3
to
f60aa21
Compare
fef313c
to
8cfff47
Compare
8cfff47
to
266df84
Compare
266df84
to
b6c152f
Compare
65794f1
to
4b6996a
Compare
4b6996a
to
f0f223b
Compare
Resolves #127, resolves #60
Player movement
The rough high-level algorithm is as follows:
Camera orientation
The logic that keeps the player oriented vertically relative to the world is handled client-side.
There are several subtleties needed to do the following: