-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Unified digital steering for smoother control #435
base: master
Are you sure you want to change the base?
Conversation
Unfortunately rm of See: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea overall, just some minor remarks. Thanks!
// full steer in original direction, | ||
// assuming player intended to reverse at that direction | ||
rawDirection = Math.signum(rawDirection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this part. I think direction should be unchanged if both left & right are pressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added more reasoning as more elaborated comments there, please review and advise further.
return MathUtils.clamp(direction, -1, 1); | ||
public class DigitalSteering { | ||
|
||
private float rawDirection = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: private member variables must have a m
prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
@@ -61,11 +62,10 @@ public Array<GameInputHandler> getAllHandlers() { | |||
public GameInput getGameInput() { | |||
mInput.braking = isBraking(); | |||
mInput.accelerating = !mInput.braking; | |||
if (!mInput.braking) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to keep the if (!mInput.braking) {
here: in this input mode, pressing both directions is used to drive backward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this meant to propagate the player action to DigitalSteering
so the trickery logic can be done there. I've elaborated the description by added comments there. I admit straight braking/reversing is sacrificed in favor of fast-reverse-at-a-direction by doing the logic there. Please review the updated comments there and give further advice.
direction = 0; | ||
} | ||
return MathUtils.clamp(direction, -1, 1); | ||
public class DigitalSteering { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This comment is for line 2 but GitHub won't let me comment on it)
You should change the copyright year and owner of this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
fb0e02b
to
0ae1a6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, sorry for dropping the ball here. I messed up and forgot to review your work. I finally did so yesterday.
Unifying steering is a really good idea. It made me realize the code in master have different behaviors for keyboard and touch inputs: when the player no longer press a direction button, keyboard handling would progressively return direction to 0, while touch handling would return it immediately.
I am not, however, convinced by the new left+right behavior: after test playing it on my phone, I found it frustrating because it is hard to predict in which direction the vehicle is going to reverse. This is especially annoying when it causes the vehicle to reverse on a turbo tile, which prevents going further. Can you revert that change?
Sorry again for the huge answering delay.
This PR make use of parabolic curve to smooth the steering control. I.e. short-press of steering btns would commit weaker control, long-press of the btns would commit stronger control. Keyboard & touch input handlers are updated uniformly.
Please review.