godot-docs icon indicating copy to clipboard operation
godot-docs copied to clipboard

"Dodge the Creeps" still uses old Input vector configuration

Open hmturnbull opened this issue 2 years ago • 4 comments

Your Godot version: v4.0.beta16.official [518b9e580]

Issue description: I'm currently working my way through the Getting Started section of the docs, and I noticed that although the 2D movement overview correctly outlines how to use the more straightforward Input.get_vector("left", "right", "up", "down") for player movement, the beginner tutorials still use the antiquated pre-3.5 technique of using four separate calls of Input.is_action_pressed(), which was honestly always a lot more confusing than the newer get_vector() method.

I think the beginner tutorials should be updated so as to teach new users the more efficient and straightforward way of handling player input, so they're not unnecessarily confused early on – and so they don't have to unlearn the old way later.

EDIT: Dodge the Creeps 3D also still has the outdated code. (see below)

URL to the documentation page (if already existing): https://docs.godotengine.org/en/latest/getting_started/first_2d_game/03.coding_the_player.html

https://docs.godotengine.org/en/latest/getting_started/first_3d_game/03.player_movement_code.html

hmturnbull avatar Jan 28 '23 04:01 hmturnbull

Agreed - is anyone currently revising this tutorial?

cbscribe avatar Jan 29 '23 20:01 cbscribe

Should get_vector() or two get_axis() be used instead? See https://github.com/godotengine/godot-docs/issues/5378 and https://github.com/godotengine/godot/pull/69028. In general, player movement should use a cross deadzone but aiming should use a circular deadzone.

Calinou avatar Jan 29 '23 22:01 Calinou

I'm not sure that distinction is really an issue for this particular application. This isn't a 3D game or even intended to be an analog-stick controlled one. Subtleties of deadzone shapes don't need to be addressed here. When using keyboard input, get_vector() is a very useful convenience.

cbscribe avatar Jan 29 '23 22:01 cbscribe

I mentioned this in a separate issue that was marked as a duplicate of this one—and I agree it's better to keep this all in one issue—but the outdated code is also present in the 3D tutorial, so I figured I'd mention it here so it's not forgotten.

Your Godot version: v4.0.beta17.official [c40020513]

Issue description: The current documentation reads as follows:

func _physics_process(delta):
    # We create a local variable to store the input direction.
    var direction = Vector3.ZERO

    # We check for each move input and update the direction accordingly.
    if Input.is_action_pressed("move_right"):
        direction.x += 1
    if Input.is_action_pressed("move_left"):
        direction.x -= 1
    if Input.is_action_pressed("move_back"):
        # Notice how we are working with the vector's x and z axes.
        # In 3D, the XZ plane is the ground plane.
        direction.z += 1
    if Input.is_action_pressed("move_forward"):
        direction.z -= 1

I think we should teach new users to use Input.get_axis(), since it's considerably more intuitive than the older pattern of using multiple calls of Input.is_action_pressed().

I was thinking something like this would work better:

func _physics_process(delta):
	# We create a local variable to store the input direction.
	var direction : Vector3 = Vector3(Input.get_axis("move_left", "move_right"), 0, Input.get_axis("move_foreward", "move_back"))

URL to the documentation page: https://docs.godotengine.org/en/latest/getting_started/first_3d_game/03.player_movement_code.html

hmturnbull avatar Feb 05 '23 21:02 hmturnbull