Skip to content
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

fix dynamic joystick to follow correctly #4

Merged
merged 1 commit into from
Jun 25, 2023

Conversation

Vrixyz
Copy link
Contributor

@Vrixyz Vrixyz commented Jun 23, 2023

a small fix to the dynamic virtual joystick, I'm moving the start_pos following the size of the interaction zone. relying on the x of the interaction zone might not be what we want, because it would be difficult to support rectangular areas.

I guess a cleaner way would be to add a property to add a follow_distance, and check on that, Dynamic could be removed in favor of that property, where a fixed or a floating joystick could follow ?

Also nitpicks:

  • I had to run a cargo update because the committed cargo.lock caused a compilation error, I didn't push it because not really relevant to my fix.
  • I had to remove the rust-toolchain file locally because I don't have the android target, and it's not really relevant to force it ?

Comment on lines +60 to +65
let to_knob = knob.current_pos - knob.start_pos;
let distance_to_knob = to_knob.length();
if distance_to_knob > half.x {
let excess_distance = distance_to_knob - half.x;
knob.start_pos += to_knob.normalize() * excess_distance;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's becoming "a lot" of code duplicated so maybe creating a function could help.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a great idea, I was thinking of doing something similar, do you think you can do it in another PR, as soon as I accept this one?

@SergioRibera
Copy link
Owner

You're right, I hadn't noticed the problem with the cargo.lock, let me see it, I'll see about the toolchain as you're right

@SergioRibera
Copy link
Owner

LGTM!

Thank you very much for your collaboration, your comments will be taken into account and I will release some commits in a moment ❤️

@SergioRibera SergioRibera merged commit 8363932 into SergioRibera:main Jun 25, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants