mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-31 09:49:06 +03:00
* General proofreading for grammar and spelling * General formatting * Addition of appropriate literals where appropriate, i.e. `&"foo"` for `StringName` cases and `^"foo/bar"` for `NodePath` cases
22 lines
537 B
GDScript
22 lines
537 B
GDScript
extends Walker
|
|
|
|
func _process(_delta: float) -> void:
|
|
var input_direction := get_input_direction()
|
|
# We only move in integer increments.
|
|
input_direction = input_direction.round()
|
|
|
|
if input_direction.is_zero_approx():
|
|
return
|
|
|
|
update_look_direction(input_direction)
|
|
|
|
var target_position: Vector2 = grid.request_move(self, input_direction)
|
|
if target_position:
|
|
move_to(target_position)
|
|
elif active:
|
|
bump()
|
|
|
|
|
|
func get_input_direction() -> Vector2:
|
|
return Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down")
|