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

Motion computation in player_input.gd #176

Open
sebastienwood opened this issue Nov 10, 2023 · 1 comment
Open

Motion computation in player_input.gd #176

sebastienwood opened this issue Nov 10, 2023 · 1 comment
Labels

Comments

@sebastienwood
Copy link

Issue description:

I am trying to replicate and understand the project as a Godot beginner, it is a mine of information on best practices.

One issues puzzles me with no solution after a lengthy research that all directed me to a fix which diverges from the demo that works fine.

The issues lies with the compute of motion in player_input.gd, here is what I need to use for the character to go in the "good direction"

motion = Vector2(
			Input.get_action_strength("move_left") - Input.get_action_strength("move_right"),
			Input.get_action_strength("move_forward") - Input.get_action_strength("move_backward"))

whereas the demo make use of:

motion = Vector2(
			Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
			Input.get_action_strength("move_back") - Input.get_action_strength("move_forward"))

Is there some trick that I am oblivious to ? If so, maybe we could comment the source code of player_input.gd to explain the process.
Thanks.

@Calinou
Copy link
Member

Calinou commented Dec 4, 2023

Note that nowadays, using Input.get_axis() (cross deadzone1) and Input.get_vector() (circular deadzone2) is recommended instead of separate Input.get_action_strength() calls.

Footnotes

  1. Recommended for player movement, so you can walk in a straight line.

  2. Recommended for aiming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants